XPath: element & attributes' name & value

Questions about XML that are not covered by the other forums should go here.
UncleRic
Posts: 4
Joined: Fri Oct 27, 2006 11:09 pm

XPath: element & attributes' name & value

Post by UncleRic »

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:

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>
The Javascript code starts out as follows:
Code:

Code: Select all


// Selecting 'id' attribute of element 'project':
var xpathResult = document.evaluate("//project[@client]", domDoc, null, XPathResult.ANY_TYPE, null );
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.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

This looks like a duplicate of this post:
http://www.oxygenxml.com/forum/ftopic2053.html

Regards,
George
George Cristian Bina
Post Reply