This content has been marked as final. Show 6 replies
How are you receiving the file? HttpListeningConnector (Integration Broker) or as a file? If from Integration Broker, then access the XML document structure from the OnRequest handler message parameter. If from a file, use the CreateXmlDoc to create an XML Document and then load it through ParseXmlFromURL or ParseXmlString.
Have a look at this thread with an example PeopleCode on how to process an XML file
I am receiving the response through HttpListening connector. If we just look at the sample XML file that i have given, I may not be able to user GetElementsByTagName and retreive the values bcos the Column Names are given as node values as below:
the rest are values
I just wanted to know is there any easier way of unparsing this kind of XML.
That is a pretty strange way of creating xml files. Actually it is an two dimensional array transformed as an XML.
What is the next step you want to do after reading the data? Based on that your XML reading code will be written.
I would read the entire XML file and create a two dimensional PeopleCode array. Use the first node as the first index and the rest of the data as the second dimension. After this you can use the array methods like Find to get the second dimension (value) based on the first dimention ( column name)
Thanks Haken. I have started of with the code.. and i believe it will work.
Is the order of the elements the same each time or do you have to use the headings to positionally identify the order of elements? If it is the same, you can use GetElementsByTagName to get an array of "ArrayofChar" elements or you can use FindNodes to return an array of XmlNode. The first element in the array would have your headings. The rest of the array would have data. You could loop over the remainder and process the rows. You can identify each of the string elements by index: GetChildNode(&idx). Your code would look something like this:
If the order can change, then loop over the &headingNode children using ChildNodeCount and GetChildNode.
Local Array of XmlNode &rows = &xmlDoc.DocumentElement.FindNodes("/ArrayofChar"); Local number &rowIdx = 1; Local XmlNode &headingNodes = &rows[&rowIdx]; While &rows.next(&rowIdx) Local string &recNo = &rows[&rowIdx].GetChildNode(1).NodeValue; Local string &personName = &rows[&rowIdx].GetChildNode(2).NodeValue; ... REM ** Process row; End-While;