P
P.Hill
I'm using jaxen to pull a few things out of DOM tree and having trouble
specifying an xPath.
/mapping/to/from[@name='Email']
works fine, but
/mapping/to[from@name='Email']
doesn't.
I'm sure it is something obvious.
I try the following xPath:
/mapping/to/from[@name='Email']
on the document (simplified for the problem:
<?xml version="1.0"?>
<!DOCTYPE mapping SYSTEM "mapping.dtd">
<mapping table="Contact" >
<to name="contact" >
<from name="Contact" />
</to>
<to name="email" >
<from name="Email" />
</to>
</mapping>
And I get the expected "from" node (the element with the attribute name="Email")
But of course looking for an Element that has nothing, but the value you are matching
is NOT very useful, so you really want some enclosing structure, in my case the enclosing
"to" element will work just fine.
So toward this end, I try:
/mapping/to[from@name='Email']
on the same DOM document and get the error.
org.jaxen.XPathSyntaxException: Unexpected '@'
at org.jaxen.BaseXPath.<init>(BaseXPath.java:136)
[...]
If
/mapping/to/from[@name='Email']
works fine, why doesn't
/mapping/to[from@name='Email']
Can anyone help?
-Paul
specifying an xPath.
/mapping/to/from[@name='Email']
works fine, but
/mapping/to[from@name='Email']
doesn't.
I'm sure it is something obvious.
I try the following xPath:
/mapping/to/from[@name='Email']
on the document (simplified for the problem:
<?xml version="1.0"?>
<!DOCTYPE mapping SYSTEM "mapping.dtd">
<mapping table="Contact" >
<to name="contact" >
<from name="Contact" />
</to>
<to name="email" >
<from name="Email" />
</to>
</mapping>
And I get the expected "from" node (the element with the attribute name="Email")
But of course looking for an Element that has nothing, but the value you are matching
is NOT very useful, so you really want some enclosing structure, in my case the enclosing
"to" element will work just fine.
So toward this end, I try:
/mapping/to[from@name='Email']
on the same DOM document and get the error.
org.jaxen.XPathSyntaxException: Unexpected '@'
at org.jaxen.BaseXPath.<init>(BaseXPath.java:136)
[...]
If
/mapping/to/from[@name='Email']
works fine, why doesn't
/mapping/to[from@name='Email']
Can anyone help?
-Paul