XPath: element & attributes' name & value
Posted: Wed Nov 08, 2006 6:52 pm
XPath neophyte here...
I want to be able to drill down into a DOM object within Firefox and extract a particular element's attributes and their values.
For example, I would like to extract the string value of the attribute 'client' which is "COUNTRYWIDE".
DOM object within Javascript:
The Javascript code starts out as follows:
Code:
All I know for now, is how to grab the particular attribute. But I haven't found any info on how to extract its value(s). Is there a [@client].getValue structure or equiv?
What would be the W3C syntax here? I can't find it.
Thanks.
I want to be able to drill down into a DOM object within Firefox and extract a particular element's attributes and their values.
For example, I would like to extract the string value of the attribute 'client' which is "COUNTRYWIDE".
DOM object within Javascript:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<powerstream version="08.00" name="powerstream" memo="" disable="n">
<project client="COUNTRYWIDE" client_code="COU" project="COUPON_LETTER" project_code="CLTR" id="1" name="project" memo="" disable="n"/>
...
</powerstream>
Code:
Code: Select all
// Selecting 'id' attribute of element 'project':
var xpathResult = document.evaluate("//project[@client]", domDoc, null, XPathResult.ANY_TYPE, null );
What would be the W3C syntax here? I can't find it.
Thanks.