webstudyer
Programmer
I have an xml file like
oldxml.xml
<ResultSet>
<data_service>
<Employeeprofile>
<row emp_name="one" org_cd="73700" rpt_to_org_cd="11111" lev="2" />
<row emp_name="four" org_cd="73656" rpt_to_org_cd="73700" lev="3" />
<row emp_name="five" org_cd="75425" rpt_to_org_cd="73700" lev="3" />
<row emp_name="three" org_cd="73723" rpt_to_org_cd="11111" lev="2" />
<row emp_name="two" org_cd="73708" rpt_to_org_cd="11111" lev="2" />
<row emp_name="Six" org_cd="73651" rpt_to_org_cd="73708" lev="3" />
</Employeeprofile>
</data_service>
</ResultSet>
I want to generate the new XML which is like this:
newxml.xml
<ResultSet>
<branch id="one">
<branchtext>one</branchtext>
<leaf>
<leafText>four</leafText>
</leaf>
<leaf>
<leafText>five</leafText>
</leaf>
</branch>
<branch id="three">
<branchtext>three</branchtext>
</branch>
<branch id="two">
<branchtext>two</branchtext>
<leaf>
<leafText>six</leafText>
</leaf>
</branch>
</ResultSet>
What is the way to do it? Using XSL? I am new in XML XSL, so would you please show me what I should do?
I use ASP to show the new xml.
Thanks in advance!
Nyan
oldxml.xml
<ResultSet>
<data_service>
<Employeeprofile>
<row emp_name="one" org_cd="73700" rpt_to_org_cd="11111" lev="2" />
<row emp_name="four" org_cd="73656" rpt_to_org_cd="73700" lev="3" />
<row emp_name="five" org_cd="75425" rpt_to_org_cd="73700" lev="3" />
<row emp_name="three" org_cd="73723" rpt_to_org_cd="11111" lev="2" />
<row emp_name="two" org_cd="73708" rpt_to_org_cd="11111" lev="2" />
<row emp_name="Six" org_cd="73651" rpt_to_org_cd="73708" lev="3" />
</Employeeprofile>
</data_service>
</ResultSet>
I want to generate the new XML which is like this:
newxml.xml
<ResultSet>
<branch id="one">
<branchtext>one</branchtext>
<leaf>
<leafText>four</leafText>
</leaf>
<leaf>
<leafText>five</leafText>
</leaf>
</branch>
<branch id="three">
<branchtext>three</branchtext>
</branch>
<branch id="two">
<branchtext>two</branchtext>
<leaf>
<leafText>six</leafText>
</leaf>
</branch>
</ResultSet>
What is the way to do it? Using XSL? I am new in XML XSL, so would you please show me what I should do?
I use ASP to show the new xml.
Thanks in advance!
Nyan