This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPath " Watch "XPath " New topic
Author

XPath

kamiya sei
Greenhorn

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) {
Parse();
}

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

Joined: Jan 18, 2011
Posts: 511
    
    3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XPath