XML file content:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Book>
<Book1 ip = "sco01" url = "www.163.com">
<Z1 name = "Chapter 1" content = "behave">
<J1 name = "section 1">
I want to be a good person. Please help me, hohoho ^_^!
</J1>
<J2 name = "section 2">
But I still want to be a bad guy ~~
</J2>
</Z1>
<Z2 name = "Chapter 2" content = "Diners">
<J1 name = "section 1">
Currently, tigers cannot eat humans ~~
</J1>
<J2 mane = "section 2">
Now, the lambs have no bones left behind by 55555.
</J2>
<J3 name = "section 3">
<H1 name = "first">
Be honest and learn more from me :)
</H1>
</J3>
</Z2>
</Book1>
<Book2 ip = "sco02" url = "www.21cn.com">
<Z1 name = "Chapter 1" content = "subject">
<J1 name = "section 1">
Agricultural Affairs Department
</J1>
</Z1>
</Book2>
</Book>
Method for calling xml in Flash:
MyXML = new XML ();
MyXML. load ("aaa. xml ");
MyXML. ignoreWhite = true;
MyXML. onLoad = function (success ){
If (success ){
// ------------------------------- Read the content in each section -------------------------------------------------------
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]);
// I want to be a good person. Please help me, hohoho success _^!
// Trace (myXML. FirstChild. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. nodeValue );
// I want to be a good person. Please help me, hohoho success _^! (Note: the first and second are J with the same function)
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [0]);
// Return, but I still want to be a bad guy ~~
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [0]. childNodes [0]);
// Returns the result that the current tiger does not eat human beings ~~
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [1]. childNodes [0]);
// Return to the current lamb and never let go 55555
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [2]. childNodes [0]);
// Return
// Trace (myXML. childNodes [0]. childNodes [1]. childNodes [0]. childNodes [0]. childNodes [0]);
// Return to the Agricultural Affairs Department
// --------------------------- Read the content in book/book1/Chapter 2/section 3/first reply ------------------------------
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [2]. childNodes [0]. childNodes [0]);
// Return To Be Honest, learn more from me :)
// --------------------------------- Read the node name -------------------------------------------------------
// Trace (myXML. childNodes [0]. nodeName );
// Return book
// Trace (myXML. childNodes [0]. childNodes [0]. nodeName );
// Return book1
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. nodeName );
// Return z1
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. nodeName );
// Return j1
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [0]. nodeName );
// Return j1 (Note: This is j1 in chapter 2)
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. nodeName );
// Return z2
// Trace (myXML. childNodes [0]. childNodes [1]. childNodes [0]. nodeName );
// Return z1 (Note: This is the z1 of book2)
// --------------------------------- Read the attributes in the node -------------------------------------------------------
// Trace (myXML. childNodes [0]. childNodes [0]. attributes. ip );
// Return sco01
// Trace (myXML. childNodes [0]. childNodes [0]. attributes. url );
// Return www.163.com
// Trace (myXML. childNodes [0]. childNodes [1]. attributes. ip );
// Return sco02
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. attributes. name );
// Return to Chapter 1
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. attributes. content );
// Returns the user
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. attributes. name );
// Return Section 1
// ------------------------------- Read length -------------------------------------------------------
// Trace (myXML. childNodes [0]. childNodes. length );
// Returns 2 (book, book2)
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes. length );
// Returns 2 (z1, z2)
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes. length );
// Returns 2 (j1, j2)
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes. length );
// Return 3 (j1, j2, j3 in chapter 2)
// -------------------------------------- Attributes of the XML class -----------------------------------------------
// FirstChild references the first child level in the specified node list
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. firstChild. childNodes [0])
// Returns the result that the current tiger does not eat human beings ~~
// LastChild references the last child level in the specified node list
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. lastChild. firstChild. childNodes)
// Return To Be Honest, learn more from me :)
// NextSibling references the next same level in the child level list of the parent node
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [0]. nextSibling. childNodes [0])
// Return to the current lamb and never let go 55555
// Previussibling references the previous same level in the child level list of the parent node
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [1]. childNodes [1]. previousSibling. childNodes)
// Returns the result that the current tiger does not eat human beings ~~
// ParentNode references the parent node of the specified Node
// Trace (myXML. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. childNodes [0]. parentNode)
// Return <j1 name = "section 1">
// I want to be a good person. Please help me, hohoho ^_^!
// </J1>
}
};
As long as you open the block function, you can see the returned content in the output.
FirstChild = childNodes [0]
FirstChild: refers to the first child level in the child level list of the parent node.
ChildNodes: An array composed of Child-level XML objects
NodeName: node name of the XML Object
Attributes: an associated array containing all attributes of a specified XML Object
NodeValue: the node value of the XML object.