1 Reply Latest reply on Apr 18, 2012 6:32 PM by Rayborn1105

    How do I remove a XML node?(Please Help)!!!!!!!!!!!!!!!

    Rayborn1105

      Hi,guys, I have trouble in manipulating XML file data in Acrobat JS. I already have a XML document and have read it.Now the XML is as below:

      <?xml version="1.0" encoding="UTF-8"?>
      <xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
      <mapData>
      <busline> 
       
      <id>4</id>

        <annotName>busline1</annotName> 
       
      <name>K222</name>
       
      <stationList>
       
      <station> 
       
      <name>FirstStation</name>
       
      <stationAnnotName>station</stationAnnotName> 
       
      <cordX>-309</cordX>  
       
      </station> 
       
      <station> 
       
      <name>222first</name> 
       
      <stationAnnotName>station3</stationAnnotName>
       
      <cordX>-315</cordX> 
       
      </station> 
       
      </stationList> 
      </busline> 
      <busline>       <-----How to delete this busline node
       
      <id>5</id> 
       
      <name>K333</name>     <-----found by its name
       
      <stationList>
       
      <station> 
       
      <name>ss</name>
       
      <stationAnnotName>station</stationAnnotName> 
       
      <cordX>-309</cordX>  
       
      </station> 
       
      <station> 
       
      <name>Target</name>   
       
      <stationAnnotName>station3</stationAnnotName>
       
      <cordX>-315</cordX> 
       
      </station> 
       
      </stationList> 
      </busline>
      </mapData>
      </xfa:data>

      In Adobe Acrobat , we have a method call XMLData.applyXPath(oXML,sringXPath).

      So how do I write the XPath or method  to delete the busline which  name is K333 from the XML node tree.

      How do I delete a busline node, if <mapData> has 3 <busline> nodes, i delete one by it's name and left the other 2.

      var root = XMLData.applyXPath(mapXML,"//mapData");


      var deleteBUSLINE = XMLData.applyXPath(mapXML,"//mapData/busline[annotName='"+willDeleteName+"']");


      root.nodes.remove(deleteBUSLINE.nodes.item(0));

       

      I write like above ,but it doesn't work.  Please Help!!!!!!!!!!!!!!!!!!!!!!!!

      I'm appreciate your help. need your help as soon as possible.