Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75370 > unrolled thread

How to loop through nodes of xml through xslt

Started byvarun bhatnagar <varun292006@gmail.com>
First post2014-07-30 14:16 +0200
Last post2014-07-30 14:16 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  How to loop through nodes of xml through xslt varun bhatnagar <varun292006@gmail.com> - 2014-07-30 14:16 +0200

#75370 — How to loop through nodes of xml through xslt

Fromvarun bhatnagar <varun292006@gmail.com>
Date2014-07-30 14:16 +0200
SubjectHow to loop through nodes of xml through xslt
Message-ID<mailman.12432.1406722601.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web