Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPath expression for finding an attribute

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB

Hi,

I am using Coldfusion to query an xml doc.

I want to be able to find an errormessage associated with a attribute ID associated with the error message.

At the moment I am using the xpath expression of /Errors/Error/ and then looping over all of the error messages that come back, and comparing the attribute with what i am looking for, but this just seems inefficient.

this is my xml structure:

Code:
<Errors>
<Error>
<ErrorMessage ID="1">
<En>My Message</En>
<Fr>My Message Fr</Fr>
</ErrorMessage>
</Error>
</Errors>

I want to be able to return the specific error message block for the ID supplied.

Any ideas?

TIA

Tony
 
<xsl:value-of select="Errors/Error/ErrorMessage[@ID = '1']/En"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top