[xml] save a part of the tree maitaining the hierarchy from root.



Hi All,
I would like to know how to save a part of a DOM tree, by maintaining the
hierarchy from the root based on an attribute/tag.
 
Suppose orig.xml is as below,
<Root>
    <Parent>
         <Child1 Apply="1">
              <Value>100</Value>
         <Child2>
               <Value>0</Value>
     </Parent>
</Root>
 
I need to save only the nodes which has the flag "Apply" (which means that
the node's value is changed), along with the complete hierarchy in another xml file.
 
new.xml would be as,
<Root>
    <Parent>
         <Child1 Apply="1">
              <Value>100</Value>
     </Parent>
</Root>
 
Just I used a simple example here. Actually the original xml file will be
a large file.
 
After identifying the nodes needed using XPATH, I tried using the
xmlElemDump( ), xmlDocCopyNodeList( )  which gets only the sub tree, not with the hierarchy.  Unlinking the nodes also did not work out, as its a large file. So, please let me know, is there any libxml-tree or save api's? or how can i get this?
 
Thanks
Senthil


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]