Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] unable to get xquery to work

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "William Chu" <willchu AT gmail.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] unable to get xquery to work
  • Date: Fri, 4 Apr 2008 00:42:27 -0700

Hello,

I am trying to apply a simple xquery to a very basic page.

The query is this: /html

The page is: <html>hi</html>

When doing so with the following code, I get no results back -
results.size is equal to 0.

Why is this happening? I am expecting that I should get "hi" back.

Thanks for the help!
Will

public class Soup {

public static void main (String argv[]) {
try {

String page = "<html>hi</html>";
ByteArrayInputStream in = new
ByteArrayInputStream(page.getBytes());
String xqueryScript = "/html";
XMLReader parser = new org.ccil.cowan.tagsoup.Parser(); //
tagsoup parser
Document doc = new Builder(parser).build(in);
System.out.println (doc.toXML());
Nodes results = XQueryUtil.xquery(doc, xqueryScript);
if (results.size() < 1) {
System.out.println ("size is less than 1");

}
System.out.println (results.get(0).toXML());
}
catch (Exception e) {
e.printStackTrace();
}
}
}




Archive powered by MHonArc 2.6.24.

Top of Page