Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPath

 
kamiya sei
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic