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

Tag Name 1

Status
Not open for further replies.

drikoudis

Programmer
Nov 1, 2003
53
0
0
GR
Hello, because i am new in XML how can i get the tag name?
<ROOT>
<NAME>Alex</NAME>
<YEAR>1950</YEAR>
</ROOT>
I want to get the string "NAME" from the <NAME> tag.

Thanks, John.
 
<xsl:template match="NAME">
<xsl:value-of select="name()"/>
<xsl:text>:&#160;</xsl:text>
<xsl:value-of select="."/>
</xsl:template>
 
If you use DOM and JavaScript :
function load()
{
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var currNode;
xmlDoc.async = false;
xmlDoc.load("nodename.xml");
try
{
currNode = xmlDoc.documentElement.childNodes.item(0);
alert(currNode.nodeName);
}
catch(e)
{
alert("error");
}
}

Thiago Falcão
 
Thanks Thiago, it's working!! Only i change the ActiveXObject("Msxml2.DOMDocument.4.0") with ActiveXObject("Microsoft.XMLDOM") and it's works.

John.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top