darma teja

darma teja

  • NA
  • 496
  • 337.4k

create different xml files by an attribute value

Jan 19 2015 5:09 AM
Hi All,

Give me some light to do this one:
My sample xml file is here: 


<?xml version="1.0" encoding="UTF-8"?>
<root rootatt="RO" rootId="1">
  <child1 id1="false" id11="1">
    <description/>
    <child id2="HIN">blabla </child>
    <target/>
  </child1>
  <child1 id1="false" id11="3">
    <description/>
    <child id2="HIN">blabla </child>
    <target/>
  </child1>
  <child1 id1="false" id11="4">
    <description/>
    <child id2="TEL">blabla </child>
    <target/>
  </child1>
  <child1 id1="false" id11="1">
    <description/>
    <child id2="TEL">blabla </child>
    <target/>
  </child1>
  <child1 id1="false" id11="7">
    <description/>
    <child id2="HIN">blabla </child>
    <target/>
  </child1>
  <child1 id1="false" id11="3">
     <description>blabla</description>
   <child id2="ARA">blabla </child>
    <target/>
 </child1>
</root>


I would like to create different xml files based on <child id2="HIN">. All same id2= "HIN" attributes including parent node (<child1>) and root node (</root>) should be in the one xml file. All same id2= "TEL" attributes including parent node (<child1>) and root node (</root>) should be in second xml file. All same id2= "ARA" attributes including parent node (<child1>) and root node (</root>) should be in the one xml file.

Advance thanks,
Darma 

Answers (2)