aspose file tools*
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
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: 535
    
    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