Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Xpath parsing problem

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Mike Miller <mm8041 AT gmail.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Xpath parsing problem
  • Date: Wed, 2 Mar 2011 19:01:22 -0500

Not sure if this went through the first time:

Hi,

I'm trying to use Xpath to drill into an xml document, I have already done
this successfully
using other simple xml documents, I say simple because there were no
namespaces or
other such things. This document has some namespace info but the tags I'm
initially trying
to get to, don't have namespace prefixes.

So my doc looks like this:
<root a bunch of namespace crap>
<warnings>
<warning>
some other nested tags in here
</warning>
</warnings>
<result>
<space>
<nb:entitycollection>
<nb:entityset> // may be multiple in doc
<nb:entity>
bunch of other tags in here
</nb:entity>
<nb:entity>
...
</nb:entity>
</nb:entityset>
</nb:entitycollection>
</space>
</result>
</root>

So I tried something like:
nodes = doc.query("/root/result/space");
then when I dumped the size of nodes, it is 0, but i expected 1 because
there is 1
in the document. I also tried something like this:
nodes = doc.query("/root/result/space/entitycollection"); and size 0 also
I want ot loop through the entitycollection children (maybe only 1) and
then from
there loop through the entityset and entity structures, But the query
using xpath
keeps saying that the list size is 0, as if it can't find any of my tags.
But if I try
to traverse the xml using getChildElements at each level, then I can see
all the
tags and children. Any ideas what the problem is?

Thanks,
Mike




Archive powered by MHonArc 2.6.24.

Top of Page