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 XPath 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 "XPath " Watch "XPath " New topic


kamiya sei

Joined: Dec 12, 2012
Posts: 25
Hi all .

I have a small application called class "XPath&XQuery".

and here is my code. Because it was too long so I just quoted part of the code, so there are questions I will add later

public static void Parse() {

Document doc = new Builder().build(new File("books.xml"));

Nodes students=XQueryUtil.xquery(doc, "@*");

for (int i = 0; i < students.size(); i++) {
Node book = students.get(i);

String name = book.getValue();

System.out.println("book name is " + name);

public static void main(String[] args) {

When I run it . 'attribute node' doesn't display??
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 591
Nodes students=XQueryUtil.xquery(doc, "@*");

By the look of it, you seem to want to find the attributes attached to the root element.

If you mean to get the attributes attached to the root element and that either you don't know the root element's name or that you just want to make it more flexible without every time commit yourself to a concrete root element's name, you can do this.
Have you checked out Aspose?
subject: XPath
It's not a secret anymore!