This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSL: cycle every element

 
Marco Rossi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need to verify if any element of an XML file contains an attribute called "id"; for example:



And this is what I wrote but it seems not working



When I print $currentNode I would like to get printed the name of the node.

Thanks
Marco
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what that "$xmlfile" variable might be, but you are only looking at its children in that code, not all of its descendants.

Why don't you just write an XPath expression which selects all nodes with an "id" attribute? That would be far easier than writing your own code to search the document.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Marco Rossi
Instead of this:
>select="$currentNode"
do this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic