Jump to content

access XHTML tree with XPath


domingoazul
 Share

Recommended Posts

Hello,I would like to change a value of my xhtml document using XPath.This is a summary of my document:

<?xml ....?><html ....>  <head>	...  </head>  <body>	...	<object>	  <param name="..." value="..." />	</object>  </body></html>

I use this XPath argument: "/html/body/object/param/@value" but it does not work.The element who uses this XPath argument is an xforms:setvalue like this:

<xforms:setvalue ref="/html/body/object/param/@value" value="instance('appletData')/ws:docRoute" />

I can do something near of what I want with Javascript, but I do not know ho to do it with XPath.Thanks

Link to comment
Share on other sites

Do you have a namespace declared in the XHTML? That is:

<html xmlns="http://www.w3.org/1999/xhtml">

If so, your XPath expression needs to specify that by using:

"/{http://www.w3.org/1999/xhtml}html/{http://www.w3.org/1999/xhtml}body/{http://www.w3.org/1999/xhtml}object/{http://www.w3.org/1999/xhtml}param/@value"

You can also simply remove the xmlns though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...