How to loop through nodes of xml through xslt

varun bhatnagar varun292006 at gmail.com
Wed Jul 30 14:16:38 CEST 2014


Hi,

I have two xml files.

*File1.xml*

*<?xml version="1.0" encoding="UTF-8"?>*
*<InfoTag>*
*<Procedure attrProc="TestProcA" attrLevel="1">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*

* <Procedure attrProc="TestProcB" attrLevel="2">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*</InfoTag>*


*File2.xml*

*<?xml version="1.0" encoding="UTF-8"?>*
*<InfoTag>*
*<Procedure attrProc="TestProcC" attrLevel="3">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*

* <Procedure attrProc="TestProcD" attrLevel="4">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*</InfoTag>*


I am trying to fetch an output file which looks like this:

*Output.xml*

*<InfoTag>*
*<Procedure attrProc="1" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
* <Procedure attrProc="2" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*<Procedure attrProc="3" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
* <Procedure attrProc="4" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>    *
*</InfoTag>*

The number of Procedure tag (<Procedure>) can be different every time. So I
have to read this tag every time from each xml and then merge it
sequentially.
Can anyone tell me how to achieve this. How can I loop every Procedure tag
and and append the attrProc attribute value in a sequential order?

Thanks,
BR,
Varun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140730/4f903159/attachment.html>


More information about the Python-list mailing list