Get XML node values and attribute values (compatible with IE and Firefox)

Source: Internet
Author: User

This article from: http://www.gerenzhanzhang.cn/post/%E8%8E%B7%E5%8F%96xox%EF%BC%89.aspx
The original article is as follows:
The XML operations in IE and Firefox differ from those in that they were depressed for an hour or two yesterday.
The following describes how to obtain XML node values and attribute values encapsulated by colleagues.

// Obtain the text value of the node.
Function getnodetext (OBJ)
{
If (! OBJ)
{
Return "";
}
If (obj. textcontent)
{
Return obj. textcontent;
}

If (obj. firstchild)
{
OBJ = obj. firstchild;
}
If (obj. nodevalue)
{
Return obj. nodevalue;
}
If (obj. Data)
{
Return obj. Data;
}
Return "";

}
Function getnodeattribute (node, name)
{
If (! Node |! Name)
{
Return false;
}
Return getattribute (name, node. attributes );
}
// Obtain an attribute
Function getattribute (name, list)
{
If (! List)
{
Return false;
}
For (VAR I = 0; I <list. length; I ++)
{
If (list [I]. nodename. tolowercase () = Name. tolowercase ())
{
Return list [I];
}
}
Return false;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.