![]() |
XPath Referencing Integer
Folks,
I've had some success with my XPath forays, mostly thanks to people on this site. I thought I'd try my luck again! I need to access the value of the WIDTH attribute of the TRIM BOX in - Code:
<od:PageBoxInfo ID="Link6">//od:PageBoxInfo/Page/PageBox[@BoxType="TrimBox"]/@Width but to no avail. Does this XPath look correct? I was thinking that the result may have been returned to me as a string rather than an integer, but I'm not sure. I'm no XPath master! Any ideas? Thanks in advance HP |
Actually, I just noticed the double quotes (") in my XPath. I changed this to single quotes (') but still the same result.
|
I am getting error due to the od: in the xml file. This maybe your problem.
May I offer an easier method, simplexml. Remove both od: and this does what you want PHP Code:
|
Thanks for your help Sunfighter. Unfortunately the XML is generated by another application we are working with and we have no option to change it. The XML is actually a Job Definition File (.jdf) and contains about 2000 lines of code (most of it useless).
It's interesting what you say about the "od:" as this appears in a lot of the file. Is there a way I can reference things without the "od:"? |
Maybe you could try something like this first
PHP Code:
|
I don’t think it’s a good idea to manually remove an XML namespace, they are there for a reason.
to the original problem: the XPath so far is correct, but the od namespace must be known to the XPath interpreter (which obviously depends on the interpreter used, XSLT is different from SimpleXML is different from DOMDocument, etc.) the return type of the XPath expression is usually a string for primitive data types (maybe except for the XPath functions), though that may also depend on the interpreter used. |
Thanks for your input guys!
I just heard back from our software developers who support the product that uses the Xpath info. Apparently the software does not support Xpath 2.0, and only supports a subset of Xpath 1.0, and they can't tell me what that subset is. :confused: I assume this is what is making things difficult (or impossible). Sorry to waste your time guys. Regards HP |
| All times are GMT +1. The time now is 12:33 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.