XML parsing and transforming (XSLT or otherwise)
- by observ
I have several xml files that are formated this way:
<ROOT>
<OBJECT>
<identity>
<id>123</id>
</identity>
<child2 attr = "aa">32</child2>
<child3>
<childOfChild3 att1="aaa" att2="bbb" att3="CCC">LN</childOfChild3>
</child3>
<child4>
<child5>
<child6>3ddf</child6>
<child7>
<childOfChild7 att31="RR">1231</childOfChild7>
</child7>
</child5>
</child4>
</OBJECT>
<OBJECT>
<identity>
<id>124</id>
</identity>
<child2 attr = "bb">212</child2>
<child3>
<childOfChild3 att1="ee" att2="ccc" att3="EREA">OP</childOfChild3>
</child3>
<child4>
<child5>
<child6>213r</child6>
<child7>
<childOfChild7 att31="EE">1233</childOfChild7>
</child7>
</child5>
</child4>
</OBJECT>
</ROOT>
How can i format it this way?:
<ROOT>
<OBJECT>
<id>123</id>
<child2>32</child2>
<attr>aa</attr>
<child3></child3>
<childOfChild3>LN</childOfChild3>
<att1>aaa</att1>
<att2>bbb</att2>
<att3>CCC</att3>
<child4></child4>
<child5></child5>
<child6>3ddf</child6>
<child7></child7>
<childOfChild7>1231</childOfChild7>
<att31>RR</att31>
</OBJECT>
<OBJECT>
<id>124</id>
<child2>212</child2>
<attr>bb</attr>
<child3></child3>
<childOfChild3>LN</childOfChild3>
<att1>ee</att1>
<att2>ccc</att2>
<att3>EREA</att3>
<child4></child4>
<child5></child5>
<child6>213r</child6>
<child7></child7>
<childOfChild7>1233</childOfChild7>
<att31>EE</att31>
</OBJECT>
</ROOT>
I know some C# so maybe a parser there? or some generic xslt?
The xml files are some data received from a client, so i can't control the way they are sending it to me.
L.E. Basically when i am trying to test this data in excel (for example i want to make sure that the attribute of childOfChild7 corresponds to the correct identity id) i am getting a lot of blank spaces. If i am importing in access to get only the data i want out, i have to do a thousands subqueries to get them all in a nice table. Basically i just want to see for one Object all its data (one object - One row) and then just delete/hide the columns i don't need.