0 Replies Latest reply on Feb 17, 2015 11:56 AM by lc_newbee

    Manipulate XML Data with XMLData.parse & XMLData.applyXPath

    lc_newbee

      Hi,

       

      I'm calling a webservice that returns a string in XML format as follow:

      <TemplateList><Template><ID>1</ID><Category> <Name>Garments</Name> <Product> <ID>6</ID><Description>Glove Cotton XL</Description><HDMSProductId>223963</HDMSProductId><LsId>223963</LsId><PopupMessage /><IsCovered>True</IsCovered><Price>0.88</Price></Product></Category></Template>/Template List>

       

      I'm trying to drill down to retrieve data from this string using XMLData.parse & XMLData.applyXPath. However, I'm having a difficult time getting the data that I need.

      Eg.

       

      var tree = XMLData.parse(TextboxData.rawvalue, false);

       

      var id = XMLData.applyXPath(tree, "TemplateList/Template");

      var description = XMLData.applyXPath(tree, "TemplateList/Template/Category/Product/Description");

       

      var templateItems = [];

       

      for (var i=0; i<id.length; i++){

      templateItems[i] = id.item(i).value + " | " + description.item(i).value;

       

      TemplateList.addItem(templateItems[i]);

       

       

       

      }