< Script Language = " Javascript " Type = " Text/JavaScript " SRC = " Sg_mirror.js " > < / SCRIPT>
< Script Language = " Javascript " >
Function Test ()
{
// VaR Doc = new activexobject ("Microsoft. xmldom ");
Alert ( " OK " );
VaR Doc = SG. xmldocument ();
VaR Returnxml = " <Root caption = \ " Trues \ " > </Root> " ;
Doc. loadxml (returnxml );
VaR R = Doc. selectsinglenode ( " Root " );
Alert (R. getattribute ( " Caption " ));
// For (INT I = 0, j = R. Attributes. length; I <j; I ++)
// {
// Alert (R. attributes [I]. value );
// }
VaR Flag = R. getattribute ( " Caption " );
If (Flag = " Trues " )
Alert ( " Registered successfully! " );
Else
Alert ( " Registration failed! " );
}
Window. onload = Function ()
{
Test ();
}
< / S
Also refer to http://blog.csdn.net/soarheaven/archive/2006/09/13/1219642.aspx
Below is the xmldocument in sg_mirror.jsCode
This . Xmldocument = Function ()
{
VaR Xmldoc = Null ;
If ( Typeof (Window. activexobject) ! = ' Undefined ' )
{
Try
{
//Xmldoc = new activexobject ("msxml2.domdocument. 5.0 ");
}
Catch (E)
{
}
If (Xmldoc = Null )
Xmldoc = New Activexobject ( " Microsoft. xmldom " );
}
Else
{
Xmldoc=Document. Implementation. createdocument ("","Doc",Null)
}
Return Xmldoc;
}