Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Looping with XML::XPath
ReggieRWalker
Env: TS 6.7.2 SP2 Win2K3
I have a logic issue with my looping code, using the XML::XPath module.
Given the following XML:
[html]
olb-timeout-module.component
olb-header-module.component
olb-body-module.component
templatedata/category/foo.xml
olb-paragraph-module.component
templatedata/category/bar.xml
olb-footer-module.component
[/html]
I am using the following subroutine (in the attached "snippet.txt") to ultimately loop through each Component node.
The problem is that I want to grab each component-specific DCR node. My loop applies the same DCR node to each Component node instance. For example, my list should be something like:
-olb-timeout.module
-olb-header.module
-olb-body.module
-DCR: /templatedata/category/foo.xml
-olb-paragraph.module
-DCR: /templatedata/category/bar.xml
-olb-footer.module
Instead it's printing:
-olb-timeout.module
-DCR: /templatedata/category/foo.xml
-DCR: /templatedata/category/bar.xml
-olb-header.module
-DCR: /templatedata/category/foo.xml
-DCR: /templatedata/category/bar.xml
-olb-body.module
-DCR: /templatedata/category/foo.xml
-DCR: /templatedata/category/bar.xml
-olb-paragraph.module
-DCR: /templatedata/category/foo.xml
-DCR: /templatedata/category/bar.xml
-olb-footer.module
-DCR: /templatedata/category/foo.xml
-DCR: /templatedata/category/bar.xml
What am I missing??
TIA
Find more posts tagged with
Comments
ReggieRWalker
Problem solved. I had to change my XPath query to something like:
foreach $dcr ($xp->find("//Component[\
@ID=
'$component_ID']/Data")->get_nodelist)