|
TopXML and www.w3schools.com both contain tutorials and references for working with XML. There is also small amounts of example code in the MSDN documentation for the classes in the System.Xml namespace.
led mike
|
|
|
|
|
I want to write a Java component to populate a table(Dojo grid) from a XML which will valid through a XML Schema (The XSD file ).That means I am having the .xsd file and have to create a table structure corresponding to the XML structure (That is .xsd file ).
Can anybody help me on giving some idea how to convert a .xsd file to its corresponding table structure .
|
|
|
|
|
Hi,
I am trying to construct a WordML document client-side in Javascript, from an XML file containing my data (obviously) and a XSLT file on the server. My code is below. How do I 'send' the generated WordML document to the browser so that it can be opened in Word?
Thanks in advance, Chris
var xslt = new ActiveXObject("Msxml2.XSLTemplate." + IA_getMSXMLVersionNumber());
var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument." + IA_getMSXMLVersionNumber());
var xslproc;
xsldoc.async = false;
xsldoc.load(XSL_URL + "/InstReport.xslt");
if (xsldoc.parseError.errorCode != 0)
{
var myErr = xsldoc.parseError;
alert("Error loading XSL: " + myErr.reason);
}
else
{
var xmlDoc;
xslt.stylesheet = xsldoc;
xslproc = xslt.createProcessor();
xslproc.input = xmlDoc;
xslproc.transform();
}
I should say that it errors whenever I reference xslproc.output
|
|
|
|
|
I am am getting a result back from the web service as an XML. When ever a new user will be in the site these web services will be called.
I have two options to parse the XML:
1. Parse and get the required nodes using XPATH.
2. Get every thing in a data set and fetch it with a reference of data table and column name.
I need to just pick one single node each time parse the XML. Please suggest me which approach I should use.
I have gone through the below article and it says:
------------8<--------------8<-----------------------------------
You should not use a dataset if:
* You are using Web Forms in your application because Web Forms and their controls are recreated each time a page is requested by the client. Thus, creating, filling and destroying a dataset each time will be inefficient unless you plan to cache it between roundtrips.
------------8<--------------8<-----------------------------------
http://www.codeproject.com/KB/cpp/dataset.aspx[^]
Please advice
Regards,
Pavas
|
|
|
|
|
|
Hence I should use the third option provided by you.
Thanks
Regards,
Pavas
|
|
|
|
|
Hi All,
I am generating a xml using asp and posting to a https link. For posting I am using MSXML2.ServerXMLHTTP.3.0 object. But, it is giving the following error while sending the xml to https link "msxml3.dll (0x80072F0C) A certificate is required to complete client authentication"
In Microsoft this is confirmed as a bug for MSXML version 2.0. But, I am using the MSXML version3.0. Also I installed the certificate(which I got from the server) in IIS properly(MSDN documentation).
var SXH_OPTION_SELECT_CLIENT_SSL_CERT = 3;
oHTTP = new ActiveXObject("MSXML2.ServerXMLHTTP.3.0");
oHTTP.open("POST", strUrl,"False","username","pwd");
oHTTP.setOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT,"LOCAL_MACHINE\\Other People\\certname");
oHTTP.setRequestHeader("Content-Type", "text/xml");
oHTTP.send(strXMLStream);
strTemp = oHTTP.responseText;
oHTTP = null;
I searched in google and got many information and tried out maximum all the options but still I am getting the same error
How can I send the xml to a https link using MSXML object and get the response? I am using IIS6.0 on windows 2003.
|
|
|
|
|
How can I convert MathML equations to TeX/LaTeX?
|
|
|
|
|
HELP!
I can import the fields of one XML file into a Excel row.
The column headings coorespond to the elements of the XML source.
How can I import multiple XML files in one shot?
Right know, when I try to import two files at the same time, only the second file contents show (This was accomplished by selecting both the two XML files in the Import XML dialog). What I would like to see is both file contents being shown in
Excel.
I tried using the option "Append new data to existing XML lists" but could not because it was de-selected (greyed out) in the XML Map Properties.
Thanks for your help,
Mike
|
|
|
|
|
For example, the person.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>
<person>
<index>
<part1>
<name>Mike</name>
<age>12</age>
</part1>
<part2>
<number>5</number>
<string>text</string>
</part2>
</index>
</person>
and the .XSL file is:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="yes"/>
<xsl:template match="/person/index/part1">
<xsl:text>name is </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>.</xsl:text>
</xsl:template>
</xsl:stylesheet>
the result is:
"name is Mike.5text"
how do I get it to read just: "name is Mike"?
Why does 5text appear?
Thanks!
Mike
|
|
|
|
|
Just add a new xsl:template element to your XSL that matches the root element. Not sure why it works this way, because I've always done it like this. But this should work for you:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="yes"/>
<!-- add this here -->
<xsl:template match="/">
<xsl:apply-templates select="/person/index/part1" />
</xsl:template>
<!-- end addition -->
<xsl:template match="/person/index/part1">
<xsl:text>name is </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>.</xsl:text>
</xsl:template>
</xsl:stylesheet>
My best guess is that you're not telling it what to do with the root "/", so it just includes everything after the match.
Mark's blog: developMENTALmadness.blogspot.com
Funniest variable name:
lLongDong - spotted in legacy code, was used to determine how long a beep should be. - Dave Bacher
|
|
|
|
|
Hello I have an XMLNode data type [I get it from web service]
When I try the
myXMLNode .SelectNodes("//*") - I get all the results
If I try
myXMLNode .SelectNodes("/Customer/") - I do not get a single nodelist
Please suggest.
Regards,
Pavas
|
|
|
|
|
Hard to tell without knowing the error message
|
|
|
|
|
Ok, these have the names paces included and I want to reach to Customer node
<CustomerSearch xmlns="http://test.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://test.com/ http://server:81/testi-schemas/dev/test.xsd">
<EventReport xmlns="http://test.com/core/events/">
<Environment>
<Validation>Off</Validation>
</Environment>
</EventReport>
<Parameters CustomerId="" AdvertisingType=" " Email="mpavas@yahoo.com"/>
<Results>
<Customer CustomerId="22334" Name="pavas malviya" Address1=" " Address2="WASHINGTONDC " Address3="DC 20431 ">
</Customer>
</Results>
</CustomerSearch>
Regards,
Pavas
|
|
|
|
|
Ok, XPath and XML file needs to be altered since you are using namespaces. Check the below one
<?xml version="1.0" encoding="iso-8859-1"?>
<CustomerSearch xmlns:ab="http://test.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://server:81/testi-schemas/dev/test.xsd">
<EventReport xmlns="http://test.com/core/events/">
<Environment>
<Validation>Off</Validation>
</Environment>
</EventReport>
<Parameters CustomerId="" AdvertisingType=" " Email="mpavas@yahoo.com"/>
<Results>
<Customer CustomerId="22334" Name="pavas malviya" Address1="" Address2="WASHINGTONDC" Address3="DC 20431"></Customer>
</Results>
</CustomerSearch> If you have the above XML file, you can get Customer node using the following XPath.
XmlDocument document = new XmlDocument();
document.Load(@"c:\XMLFile1.xml");
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable);
XmlElement customerSearchElement = document.DocumentElement;
XmlNode customerNode = customerSearchElement.SelectSingleNode("descendant::Results/Customer", namespaceManager);
if (customerNode != null)
Also check some beginer tutorial on XPath and writing XML namespaces.
Hope this helps
|
|
|
|
|
Of course it oesn't work. The // in the first xpath works on all levels. / in the second, works from the top, you have no top level nodes called customer. //Customer will work
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So How can I do it I tried adding the namespace and tried the below code
NameTable nt = new NameTable();
nsm = new XmlNamespaceManager(nt);
nsm.AddNamespace("autn", "http://test.com/");
SelectNodes("/Costomer/Results",nsm)
Now I tried the above namespace code in C# But still no results.
Please advice
Regards,
Pavas
|
|
|
|
|
mpavas wrote: Costomer
Does help if you spell it right.
Please buy a book on XML and read it. And, read my reply again. Like I said, // works because it scopes all nodes, so //Customer will find a Customer node anywhere in your XML, but /Customer only finds top level nodes.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes, I should use the correct names mY mistake sorry for writing it wrong and creating confusions
In below xpath a = 'http://test.com/'
/a:CustomerSearch : I get all the records [I am using Mozilla add on for XPATH checker]
/a:CustomerSearch/Results : I do not get any elements for this XPATH.
As i am not getting the results I am writing //* as xpath and use nodelist item number for reference.
Regards,
Pavas
|
|
|
|
|
For example,
take:
"<"?xml version="1.0" encoding="UTF-8"">"
"<"person">"
"<"name>Mike"<"/name">"
"<"age>12"<"/age">"
"<"/person">"
"<"ENDOFXML">"
and store it into:
struct person
{
string name;
int age;
}
so that the main program would appear as:
int main
{
person a;
a.name = "Mike";
a.age = 12;
return 0;
}
Thanks
-Mike
|
|
|
|
|
It should be pretty straightforward to write an XSL stylesheet to do this. The output type of the stylesheet would need to be Text.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Would you please show me how to do this with my small example?
I appreciate your help,
-Mike
|
|
|
|
|
Here you go.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:text>int main { </xsl:text>
<xsl:apply-templates />
<xsl:text> return 0; }</xsl:text>
</xsl:template>
<xsl:template match="person">
<xsl:text>person a; a.name = </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>; a.age = </xsl:text>
<xsl:value-of select="age"/>
<xsl:text>; </xsl:text>
</xsl:template>
</xsl:stylesheet>
Hope it helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
What does the .xml file look like?
Doesn't it have to have a reference to the .xsl file?
Do both the .xml and the .xsl have to co-exist in the same file?
Thanks,
Mike
|
|
|
|
|
Mike A. Fowler wrote: What does the .xml file look like?
Like the XML fragment you included in your original post, minus the ENDOFXML element.
Mike A. Fowler wrote: Doesn't it have to have a reference to the .xsl file?
Not necessarily. You can directly link an XML document to an XSL stylesheet by including the following declaration below your XML declaration:
<?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>
If the XML file is viewed in a browser like IE, the browser will perform the transformation and display the result.
Mike A. Fowler wrote: Do both the .xml and the .xsl have to co-exist in the same file?
No, the XML and XSL documents reside in separate files. It wouldn't make any sense for the two to be in the same file. The stylesheet would be tightly coupled to a single XML document and couldn't be applied to other documents.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|