This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XSL: cycle every element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL: cycle every element" Watch "XSL: cycle every element" New topic

XSL: cycle every element

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
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.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19719

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

Joined: Jan 18, 2011
Posts: 590
@Marco Rossi
Instead of this:
do this
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: XSL: cycle every element
It's not a secret anymore!