? Error in code called by an XML Object in Javascript

Source: Internet
Author: User
User. xml:

<? XML version = "1.0" encoding = "gb2312" ?>
< User >
< Name > Love flying </ Name >
< Password > 123 </ Name >
< Friendnum > 4 </ Friendnum >
</ User >

Ex35.htm: (main part)

User name: < Input Name = "Username" Type = "Text" ID = "Username" >
< P >
Password: < Input Name = "Password" Type = "Text" ID = "Password" >
</ P >
< P >
< Input Type = "Submit" Name = "Submit" Value = "Submit" Onclick = "Checkuser ()" >
</ P >
< XML ID = "Userxml" SRC = "User. xml" > </ XML >
< Script Language = "JavaScript" >
Function Checkuser ()
{
VaR Usernamenode = Userxml.xmldocument.doc umentelement. selectnodes ( " Name " );
VaR Usernamer = Usernamenode ( 0 ). Firstchild. nodevalue;
VaR Userpasswordnode = Userxml.xmldocument.doc umentelement. selectnodes ( " Password " );
VaR Userpasswordr = Userpasswordnode ( 0 ). Firstchild. nodevalue;
VaR Userfriendnode = Userxml.xmldocument.doc umentelement. selectnodes ( " Friendnum " );
VaR Userfriendn = Userfriendnode ( 0 ). Firstchild. nodevalue;
If (Username. Value = Usernamer && Password. Value = Userpasswordr)
{
Alert ( " Welcome, " + Username. Value + " ! Your address book now has " + Friendnum. Value + " Friend " );
Location. href = " Ex35.xml " ;
}
Else
{
Alert ("Incorrect username and password!");
Clearname ();
Clearpassword ();
}
}
</ Script >

In addition, there is an ex35.xml file used to display the results.

I wrote on the book, but it is always wrong to run ex35.htm, saying "userxml.xmldocument.doc umentelement is empty or not an object".
Please help me!

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.