|
Well do you just need to read in a string and then save it as a CData section to a single element? I would expect you wanted to organize the data in some hierarchical scheme.
Have you just browsed the XML code here in CP and looked for examples?
Kristen Wegner's is good work (along with many others) http://www.codeproject.com/soap/pugxml.asp[^]
There are several "SET" methods to add elements, attributes and their values.
""
|
|
|
|
|
Hi,
I have a xml file (e.g. mydata.xml). How am I able to make use of javascript to select elements to be displayed on a HTML?
E.g. Using dropdown menu, I select 'Name'. Onclick the Submit button will enable the javascript to pull out all the 'Name' elements in mydata.xml and display on IE. Is this possible?
Also, possible to have logical 'AND' function?
Thanks in advance.
|
|
|
|
|
Just FYI,
Roger Costello has updated his excellent tutorials and white papers. Feb 2003
xfront[^]
""
|
|
|
|
|
How do i append data to an existing XML file using C#? I have two processes that need to populate the same XML file.
|
|
|
|
|
XmlDocument doccy = new Document();<br />
doccy.Load(filename);<br />
<br />
XmlElement root = doccy.SelectSingleNode("rootnode");<br />
<br />
XmlElement newRecord = doccy.CreateElement("record");<br />
root.AppendChild(newRecord);<br />
<br />
doccy.Save(filename);
obviously you will need to implement a locking mechanism.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I read that IE still uses msxml 2.0 for xml processing. Is this correct?
If I want to include xml functionalities in my vc++ app, is it recommended to use msxml4.0 sdk? I hate to redistribute msxml4.0 with my app. assuming that most people have IE 5+, couldn't I just use msxml2.0? (i can't seem to find much information on msxml sdk prior to version 3)
thanks in advance,
|
|
|
|
|
Version 3.0 of MSXML is shipped with IE5+, IE use what you tell it to use, while default is MSXML3 (not 4), for example if you create an instance of MSXML in the script with string "MSXML2.DOMDocument", version 3 will be used (assuming it is installed), but if you use "MSXML2.DOMDocument.4", you'll get a version 4.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
:(hi all,
I am new to this forum..but not new to CP..can anyone of you help me out..I have an XML document and I parsed it to get the data..and show it in in IE 5.0 but the same thing doesnt work in Netscape..I am having Netscape 6.1...I am using Javascript to render XML..Any help or pointers are welcome..Please help..
thanks in advance..
Cheers
Himanshu
|
|
|
|
|
Post the code please xxhimanshu, then we can help. Just saying "using Javascript to render" does not help us much.
Paul Watson Bluegrass Cape Town, South Africa
Macbeth muttered:
I am in blood / Stepped in so far, that should I wade no more, / Returning were as tedious as go o'er
DavidW wrote:
You are totally mad. Nice.
|
|
|
|
|
hi,
i cannot understand what code.. the code that i used does well in IE..and does everything I want to do..and the way i want to...but I want to know as I am creating a DOM for microsoft as new ActiveXObject("Msxml2.DOMDocument.3.0");...and also some other things which work fine in IE doesnt work in NETSCAPE..as document.all doesnt work..whatever I have searched for and found was like that..I will have to use XSL Stylesheets..to render XML and show it in Netscape.....but I am having a problem..I dont have a static XML file...so I cant create a XSL which is dynamic...so is there any other way to do it..as we do in Microsoft Internet Explorer..any hints and ideas are welcome..please help!!!!!!!!!
TIA...
himanshu
|
|
|
|
|
The code I meant was your code which is giving the problem on Netscape. If you can post that code then maybe we can help you out.
From what I can gather though I recommend you ditch the client side processing and do it all server side. It is perfectly possible to apply an XSL transform to a dynamic XML source.
The best way is to have an ASPX (or ASP page) which creates an XmlDocument and XslTransform . you then load up the XmlDocument with your dynamic XML (in .NET it can take in streams or physical files) and Response.Write out the XslTransform output.
Paul Watson Bluegrass Cape Town, South Africa
Macbeth muttered:
I am in blood / Stepped in so far, that should I wade no more, / Returning were as tedious as go o'er
DavidW wrote:
You are totally mad. Nice.
|
|
|
|
|
I did it for IE..ad it is working fine..but the same program doesnt give any output in netscape..that is because netscape doesnt support some of the methods..so there is no other way..than to write a new approach which either can work fine in both..IE and netscape..or write routines for netscape and IE...but I dont know the idea as how to start with...can you help me out..
cheers
Himanshu
|
|
|
|
|
you have to do this using server-side code.
client side code is not a good idea as you will face the problems that you have now.
you need to write this in code that executes on the webserver, so either asp or asp.net depending on which one you know.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi,
I am using MSXML to get the response from a web server. It's really strange that everytime before I can load that page successfully, I should load that url first in my IE. Only after that, the page can be loaded in my program.
Can someone kindly tell me what the problem could be?
Thanks and nice day!
<br />
BOOL CAPIDlg::MakeRequest() {<br />
try{<br />
MSXML::IXMLHttpRequestPtr pIXMLHTTPRequest;<br />
HRESULT hResult=CoInitialize(NULL);;<br />
hResult = pIXMLHTTPRequest.CreateInstance("Microsoft.XMLHTTP");<br />
pIXMLHTTPRequest->open("POST",(_bstr_t)"http://www.yahoo.com");<br />
pIXMLHTTPRequest->send();<br />
m_XMLResult.SetWindowText(pIXMLHTTPRequest->responseText);<br />
}<br />
catch(...) {<br />
}<br />
return true;<br />
}<br />
|
|
|
|
|
Hi, I find out the mistake
The method is
pIXMLHTTPRequest->open("POST",(_bstr_t)"http://www.yahoo.com");
shoud be "GET" instead of "POST".
|
|
|
|
|
how to do the following using .NET
I have the following XML document :
<a>3.14159</a>
If I were using COM MSXML parser, I could get
NodeTypedValue property to get "strongly-typed"
value.
b= XMLDocument.SelectSingleNode("//b");
variant value = b.NodeTypedValue;
//now the variant contains double value.
The question is:
how to achieve the same using C# ?
Value property of XMLNode object returns String
type, wchich i have to convert to get desired type...
How to do this without explicit conversion (by the means
of XMLConvert class or similar...)
Thanks
Michal Januszczyk
|
|
|
|
|
I have an XML document which is as follows :
<NODE name="a">
<NODE name="b">
<NODE name="c"/>
</NODE>
</NODE>
the XSL output needs to be
a
b
c
can i do this using XSL? I am unable to do a nested looping that indents . Please help .
|
|
|
|
|
Hi,
here's an example of this I knocked together for a friend a while ago..
*********XML*********
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="xmlnav.xsl"?>
<navigation>
<menu name="menu 1">
<option name="LEVEL 1" path="/xmlnav/level1.asp">
<option name="test level 1" path="/xmlnav/level1test.asp">
<option name="test level 1 sub option" path="/xmlnav/suboption.asp"/>
<option name="test level 1 sub option 2" path="/xmlnav/level1test.asp">
<option name="test level 1 sub sub option" path="/xmlnav/suboption.asp"/>
</option>
</option>
<option name="test level 2" path="/xmlnav/level2test.asp"/>
<option name="test level 3" path="/xmlnav/level3test.asp"/>
</option>
</menu>
<menu name="menu 2">
<option name="LEVEL 2" path="/xmlnav/level2.asp">
<option name="test menu2 sub option" path="/xslnav/suboption2.asp"/>
</option>
</menu>
</navigation>
---------------8<---------------
*********XSL*********
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="path"/>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
body, td { font-family: arial; font-size: 12px }
</style>
</head>
<body>
<p>Matching company: <xsl:value-of select="$path"/></p>
<xsl:for-each select="navigation/menu">
<xsl:value-of select="@name"/><br/>
<xsl:for-each select="child::option">
<xsl:call-template name="alink">
<xsl:with-param name="nesting" select="0" />
<xsl:with-param name="loop" select="0" />
</xsl:call-template>
<br />
<xsl:call-template name="chld" >
<xsl:with-param name="nesting" select="0" />
<xsl:with-param name="loop" select="0" />
</xsl:call-template>
</xsl:for-each>
<br />
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template name="chld">
<xsl:param name="loop" />
<xsl:param name="nesting" />
<xsl:for-each select="child::option">
<xsl:call-template name="alink">
<xsl:with-param name="loop" select="$loop" />
<xsl:with-param name="nesting" select="$nesting + 1" />
</xsl:call-template>
<br />
<xsl:call-template name="chld">
<xsl:with-param name="loop" select="$loop" />
<xsl:with-param name="nesting" select="$nesting + 1" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="space">
</xsl:template>
<xsl:template name="alink">
<xsl:param name="loop" />
<xsl:param name="nesting" />
<xsl:if test="not($loop > $nesting)">
    
<xsl:call-template name="alink">
<xsl:with-param name="loop" select="$loop + 1"/>
<xsl:with-param name="nesting" select="$nesting"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$loop=$nesting">
<a>
<xsl:attribute name="href"><xsl:value-of select="@path"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
---------------8<---------------
that should be more than enough to get you going
if you need an explanation then give me a shout, and I will do my humble best to clarify it.
HTH
|
|
|
|
|
This work ok . I had one more question . Now How can i diagramatically represent this heirarchical data ? Like everything is in One level I need some indentation !
Like
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
this would be really cool . This seems easy when programming in C/C++ , but how do i make XSL do this ?
|
|
|
|
|
Dinner time so I have to go.
Look up the parameter passing to templates. One option would be to just send a text string of blanks that is increased with each call and put that text out prior to the name you have.
www.w3schools should have a sample
""
|
|
|
|
|
My XML Document is the following
<OBJECT Class="CRange" Name="objName"><br />
<OBJECT Class="CKeyboard" Name="objName"/><br />
<OBJECT Class="COven" Name="objName"><br />
<OBJECT Class="CDigitalInput" Name="objName"/><br />
<OBJECT Class="CDigitalOutput" Name="objName"/><br />
</OBJECT><br />
<OBJECT Class="CSettings" Name="objName"/><br />
</OBJECT>
My XSLT CODe is as
<?xml version="1.0" encoding="ISO-8859-1"?><br />
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><br />
<xsl:template match="/"><br />
<html><br />
<body><br />
<h2>AOM MODEL</h2><br />
<br>top</br><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"/><br />
</xsl:for-each><br />
</xsl:for-each><br />
<br />
<br />
<br />
</body><br />
</html><br />
</xsl:template><br />
<xsl:template match="OBJECT"><br />
<span style="color:#0000FF"><br />
<br><br />
<xsl:value-of select="@Class"/><br />
</br><br />
</span><br />
</xsl:template><br />
<xsl:template match="PROPERTY"><br />
<br><br />
<span style="color:#ff0000"><br />
<xsl:value-of select="."/><br />
</span><br />
</br><br />
</xsl:template><br />
</xsl:stylesheet>
The output is
AOM MODEL
top
CRange
CKeyboard
COven
CSettings
CDigitalInput
CDigitalOutput
This does not reflect the heirarchy and is wrong . What should i be doing to get
AOM MODEL
top
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
what am i doing wrong ? I basically need a tree traversal ? Please help
|
|
|
|
|
Is this what you want?
What processor are you using?
I had to change the xmlns to something newer to run this through MSXML 4.
I also had to correct the case of the match and select values to your xml file.
**************** XML FILE *****************
<object Class="CRange" Name="objName">
<object Class="CKeyboard" Name="objName"/>
<object Class="COven" Name="objName">
<object Class="CDigitalInput" Name="objName"/>
<object Class="CDigitalOutput" Name="objName"/>
</object>
<object Class="CSettings" Name="objName"/>
</object>
*************** XSL FILE ********************
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>AOM MODEL</h2>
<br>top</br>
<xsl:apply-templates select="object"/>
</body>
</html>
</xsl:template>
<xsl:template match="object">
<span style="color:#0000FF">
<br>
<xsl:value-of select="@Class"/>
</br>
</span>
<xsl:apply-templates select="object"/>
</xsl:template>
<xsl:template match="PROPERTY">
<br>
<span style="color:#ff0000">
<xsl:value-of select="."/>
</span>
</br>
</xsl:template>
</xsl:stylesheet>
************** out put ******************
AOM MODEL
top
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
<b><i>""</i></b>
|
|
|
|
|
How to display More than one XML file data using same XXLTransform object?
|
|
|
|
|
I have a xml-schema in which two elements are defined, as in code below. The first one is included in the second one using ref=”element1”. From this schema I define a dataset using DataSet.ReadXmlSchema() (in C#). The simple data types, as string and int are easy to store data in, but how do I store an object of the first element type into the dataset? I have tried to first store it in a DataRow (defined as in the xml-schema of element1) and then add it to the other Dataset, but this does not work. An Int32 type is expected for the ref-element, is this a handle to the other element? If so how do I get that handle?
Any help will be greatly appreciated!
/EnkelIk
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Register" xmlns:xs = "http://www.w3.org/2001/XMLSchema" version ="1.0"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Element1">
<xs:complexType>
<xs:sequence>
<xs:element name="str1" nillable="true" type="xs:string" />
<xs:element name="str2" nillable="true" type="xs:string" />
<xs:element name="str3" nillable="true" type="xs:string" />
<xs:element name="str4" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Element2">
<xs:complexType>
<xs:sequence>
<xs:element name="mystr1" nillable="true" type="xs:string" />
<xs:element name="mystr2" nillable="true" type="xs:string" />
<xs:element ref="Element1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
|
|
|
|
I'm having problems defining an array in xml.
I have defined an xml schema in a file and I create a dataset by loading the schema (in C#: DataSet.ReadXmlSchema(filename) ). It works fine for "complex types" containing strings, ints and so on, but when I try defining an array the error message reads:
"Undefined complexType 'http://schemas.xmlsoap.org/soap/encoding/:Array' is used as a base for complex type restriction".
How come the Array type is undefined? Many schemas use the same syntax from what I can tell. What am I missing?
Below is part of the xml-schema I try to use:
<xs:schema id="Register" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:s3="http://vo.lpw.ldk" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/">
<xs:element name="Register" msdata:isdataset="true" msdata:locale="sv-SE">
<xs:complextype>
<xs:choice maxoccurs="unbounded">
<xs:element name="ArrayOf_tns3_ProgRes">
<xs:complextype>
<xs:complexcontent mixed="false">
<xs:restriction base="soapenc:Array">
<xs:sequence>
<xs:element name="item" type="ProvRes" minoccurs="0" maxoccurs="unbounded">
<xs:attribute d7p1:arraytype="s3:ProvRes[]" ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/">
<xs:element name="ProgRes">
<xs:complextype>
<xs:sequence>
<xs:element name="string1" nillable="true" type="xs:string">
<xs:element name="string2" nillable="true" type="xs:string">
Best regards
/EnkelIk
|
|
|
|