Forum Discussion
pravin_k99
Contributor
Thanks Robert and Tanya
I wrote this piece of code but unfortunately, it works only when I remove namespaces from the XML.
<BasicExport xmlns="http://www.in.casds.com/SSR/XTI/Traffic/0011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.uk.nds.com/SSR/XTI/Traffic/0011 0011_export.xsd" transactionIdentifier="585073235185"> REPLACED with <BasicExport>
function FirstValue() { var Doc, s, Nodes, ChildNodes, i, Node; Doc = getActiveXObject("Msxml2.DOMDocument.6.0"); Doc.async = false; Doc.load("C:\\mytest.xml"); if(Doc.parseError.errorCode != 0) { s = "Reason:\t" + Doc.parseError.reason + "\n" + "Line:\t" + aqConvert.VarToStr(Doc.parseError.line) + "\n" + "Pos:\t" + aqConvert.VarToStr(Doc.parseError.linePos) + "\n" + "Source:\t" + Doc.parseError.srcText; Log.Error("Cannot parse the document.", s); return; } Nodes = Doc.selectNodes("//caProductId"); Log.Message(Nodes.item(1).childNodes.item(1).text); }
Though there is an example for namespace based XML. My XML seems to have namespace only in the first tag and then the rest of the xml doesnot use the namespace.
Can you please help?
TanyaYatskovska
6 years agoSmartBear Alumni (Retired)
Hi,
What do you mean when you say " the code doesn't work"? Do you see any errors/exceptions? Please post them here.
Also, it's worth seeing your xml file (at least the structure of the file). Could you please post it here?
- TanyaYatskovska6 years agoSmartBear Alumni (Retired)
Related Content
- 4 years agorajs2020
- 5 years agoKrishna_Kumar
Recent Discussions
- 3 days agovladd1