Win a copy of Design for the Mind this week in the Design 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: 20945
31
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic