Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Hello,
S_Swaminathan_(maninfoadmin_-_(deleted))
Hello, I am trying to parse a xml string and get the contents of the xml in Oscript. For ex xml string will be like 123 456 789Can any body give me the code of reading the xml elemtns and their values. I dont know any thing on how to do this.Thanks & Regards
Find more posts tagged with
Comments
Francisco_Alcala-Soler_(iaea_001user3_-_(deleted))
Message from via eLinkHi,> Posted by Swaminathan, S on 09/22/2004 07:38 AM>> I am trying to parse a xml string and get the > contents of the xml in Oscript. For ex xml string will be like> > > 123> 456> 789> > > Can any body give me the code of reading the xml elemtns and > their values. I dont know any thing on how to do this.One possible way of doing this is to write your XML string to a temporary file and then use Livelink's SAX/DOM parser to create an XML document in memory which you can use to access the element names and values. You need to write the string to a file, because the parser can handle only file names of DOMDocuments as parameters, I think.Some code follows (warning: untested code, I am not sure if I'm getting the hierarchy of XML nodes correctly below): String xmlFile = 'C:\myTempFile.xml' Integer item DOMParser xmlParser DOMDocument xmlDocument DOMNode xmlRootNode, xmlNode, xmlChildNode DOMNodeList xmlList DOMText xmlChildNodeText Assoc result = Assoc.CreateAssoc() Assoc retVal = Assoc.CreateAssoc() retVal.ok = TRUE retVal.errMsg = UNDEFINED xmlParser = DOMParser.New() result = xmlParser.Parse( xmlFile ) if ( !result.ok ) retVal.ok = FALSE retVal.errMsg = Str.Format( "Error parsing XML document '%1': %2", xmlFile, result.errors[1].errMsg ) end if ( retVal.ok ) xmlDocument = xmlParser.GetDocument() // There is another function to get the root node, I think, this is only an example... xmlList = xmlDocument.GetElementsByTagName( "test" ) xmlRootNode = xmlList.Item( 0 ) xmlList = xmlRootNode.GetChildNodes() for item = 0 to ( xmlList.GetLength() - 1 ) xmlNode = xmlList.Item( item ) xmlChildNode = xmlNode.GetFirstChild() if ( IsDefined( xmlChildNode ) ) xmlChildNodeText = xmlChildNode.Cast() if ( xmlChildNodeText.GetNodeType() == DOMNode.TEXT_NODE ) // The values you're looking for are next. // Place them in an array or whereever you like before the next iteration. String myContentElement = xmlNode.GetNodeName() String myContentValue = Str.String( xmlChildNodeText.GetData() ) end end end endHope this helps, CurroThis email message is intended only for the use of the named recipient.Information contained in this email message and its attachments may beprivileged, confidential and protected from disclosure. If you are not theintended recipient, please do not read, copy, use or disclose thiscommunication to others. Also please notify the sender by replying to thismessage and then delete it from your system.