Comments (4)
  • Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

1 KrishnaGuda commented Permalink

I would think this is a NECESSARY tool when you are writing REST Clients. If you are trying with plain XML for Records please make sure to add "<?xml version="1.0" encoding="utf-8"?>" as the first line.

2 AaronAllsbrook commented Permalink

Hi Jing, <div>&nbsp;</div> This was very helpful for parsing a simpleAPI produced by a thirdparty. Since I struggled with where to go after I had the record structure defined, I thought I would include the next steps I used to get the data actually into the record structure. TrailersRec is the structure the xml2record helped me define. - The technique well documented in the help of course. <div>&nbsp;</div> function myCall(e event in)<br /> s IRest{@restBinding{}};<br /> urlInfo string = "http://simpleapi.traileraddict.com/trailer/"<i>clickedMovieName</i>"/trailer";<br /> call s.invokeGet(urlInfo) returning to getXmlResult onException ServiceLib.serviceExceptionHandler {timeout = 3000000};<br /> end<div>&nbsp;</div> function getXmlResult(retResult string in)<br /> trailersRec TrailersRec{};<br /> try<br /> XmlLib.convertFromXML(retResult, trailersRec); <br /> onexception (e RuntimeException)<br /> writestdout(e.message);<br /> end<br /> end

3 jingqian commented Permalink

Hi Allan,<div>&nbsp;</div> Thanks for the post. <div>&nbsp;</div> EGL now has a much better/complete tool to help you to define EGL record from xml/json or xml schema, it also supports name spaces.<div>&nbsp;</div> You can check it out at<div>&nbsp;</div> <a class="jive-link-external" href="http://comm05.haw.ibm.com/EGLRecordConversionServices/transform-en_US.html">http://comm05.haw.ibm.com/EGLRecordConversionServices/transform-en_US.html</a>

4 Ortwin commented Permalink

Allan thanks for the post.
I always like unambiguous sample code.

 
In my case the XML contained unescaped characters which caused the convertFromXML function to fail. I resolved this by first escaping the characters like:

length int = characterLen(retResult);for (i int from 1 to length)    if (retResult[i:i] == "&")                retResult = retResult[1:i-1] + "&amp;" +  retResult[i+1:length];          i += 5;         length += 4;    endendretResult = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + retResult;