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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing xml data with XML DOM and javascript

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all,

i do have an xsl where i call a javascript function inside :

Code:
	<xsl:for-each select=&quot;./*[1]&quot;>
		<tr bgcolor=&quot;6699cc&quot;>
			<xsl:for-each select=&quot;./*&quot;>
				<td>
					<xsl:value-of select=&quot;user:getName(.)&quot;/>
				</td>				
			</xsl:for-each>
		</tr>
	</xsl:for-each>
and here is the script inside the xsl :
(code]


<xsl:stylesheet xmlns:xsl=&quot; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; xmlns:user=&quot;urn:user-namespace-here&quot; version=&quot;1.0&quot;>
<msxsl:script language=&quot;javascript&quot; implements-prefix=&quot;user&quot;>
<![CDATA[
function getName(node)
{
return node.item(0).nodeName;
}
]]>
</msxsl:script>


[/code]
here is my xml structure :
Code:
<results>
	<result>
		<field name=&quot;Project Site&quot;>Paris</field>
		<field name=&quot;end date&quot;>07/04/2001</field>
		<field name=&quot;Project name&quot;>Microsoft Visio 10 VS Help </field>
		<field name=&quot;Project Code&quot;>ITOSE01001</field>
		<field name=&quot;Status&quot;>Go</field>
	</result>
        ....
</results>
the problem is that my function returns me the name of the node (field) and in fact i'd like to get the value of the &quot;name&quot; attribute (example : end date).
i tryed to put
return node.attributes(0).getNamedItem(&quot;name&quot;);

but it doesn't work.

so can someone give me the correct syntax please ?

Best regards,
Elise, XML learning girl X-)
 
node(0).attributes.getNamedItem(&quot;name&quot;);


was the answer Best regards,
Elise, XML learning girl X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top