Forum Discussion
What I've done in the past is create an instance of the MSXML2.DOMDocument object and do my parsing and examination that way. There are methods for "GetNode" and such built into that object that allows you to return all child nodes of a particular search pattern as an array that you can then navigate or reference by index.
See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754523%28v%3dvs.85%29
- pravin_k996 years agoContributor
Sorry
The link seems to be broken. Would you be able to post your solution here please?
Thanks
- tristaanogre6 years agoEsteemed Contributor
pravin_k99 wrote:
Sorry
The link seems to be broken. Would you be able to post your solution here please?
Thanks
The link is corrected... the page referenced gives some examples in JScript code. The link TanyaYatskovska provided gives some code examples as well. I don't have the code at my fingertips... that was at a different job so not immediately available and, unfortunately, I don't have time to reinvent it...
- pravin_k996 years agoContributor
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?
Related Content
- 2 years agodavid-beltran
- 4 years agorajs2020
Recent Discussions
- 12 hours agoSvetaG