View Full Version : Reading the values of XML tag attributes
Skyzyx
12-02-2002, 04:00 PM
I've been to www.youngpup.net (this guy is brilliant!). Anyways, I was reading some of his content which is in XML files, and noticed that he had a script there somewhere that was able to read and display the value of an attribute in an XML tag. I looked through his source code, and didn't see it, although obviously, it was there somewhere... I just must have missed it.
Anyways, does anyone know of a cross-platform way of reading these attributes?
Thanks
-- Sky
Skyzyx
12-17-2002, 02:33 AM
I'm going to bump this thread, k?
brothercake
12-17-2002, 11:36 AM
assuming you're talking XSL ...
<xsl:value-of select="node" />
<xsl:value-of select="@attribute" />
You can add node/attribute values into other strings like
<a href="{url}">
or
<a href="{@url}">
I think that's right :o
Skyzyx
12-17-2002, 10:58 PM
That's good, but I'm looking for a JavaScript way to do it. I know that HTML tag attributes can be read with getAttribute(), but I wasn't sure if a similar way could be used for XML.
Alex Vincent
12-18-2002, 10:29 PM
The getAttribute() method of Element is a DOM Core method; it will work from XML. The key is for the document to recognize your script element in the first place:
<script xmlns="http://www.w3.org/1999/xhtml" type="application/x-javascript"><![CDATA[
// script here
]]></script>
Skyzyx
12-19-2002, 06:06 AM
You've been a tremendous help. I appreciate it!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.