PHP reads XML in the third case: the XML file (Cy.xml) is as follows:
1
2
3
4
5
6
The php file (cy.php) is as follows (and the first time remains unchanged):
Load (' Cy.xml '); foreach ($xml->getelementsbytagname_r (' list ') as $list) {$value = $list->firstchild-> Nodevalue;echo $value. "
";}? >cy.php output: 123456===========php read XML fourth case, keep cy.xml unchanged, change Cy.php:XML file (Cy.xml) as follows:
1
2
3
)
4
5
6
The php file (cy.php) is as follows:
Load (' Cy.xml '), $main = $xml->getelementsbytagname_r (' main '), foreach ($main as $main) {$list = $main Getelementsbytagname_r ("list"), foreach ($list as $list) {$value = $list->firstchild->nodevalue; PHP reads XML in the third case: the XML file (Cy.xml) is as follows:
1
2
3
4
5
6
/c7>
The php file (cy.php) is as follows (and the first time remains unchanged):
Load (' Cy.xml '); foreach ($xml->getelementsbytagname_r (' list ') as $list) {$value = $list->firstchild-> Nodevalue;echo $value. "
";}? >cy.php output: 123456===========php read XML fourth case, keep cy.xml unchanged, change Cy.php:XML file (Cy.xml) as follows:
1
2
3
4
5
6
The php file (cy.php) is as follows:
Load (' Cy.xml '), $main = $xml->getelementsbytagname_r (' main '), foreach ($main as $main) {$list = $main Getelementsbytagname_r ("list"), foreach ($list as $list) {$value = $list->firstchild->nodevalue; echo $value. "
";}}? >cy.php output: 123456 Why two times cy.php is different, but the output is the same? Let's take a look at the next example ==============php read the fifth case of XML, change the Cy.xml, and keep cy.php in the fourth case: The XML file (Cy.xml) is as follows:
1
2
3
4
5
6
7
8
9
PHP files (cy.php) are the same as in the fourth case:
Load (' Cy.xml '), $main = $xml->getelementsbytagname_r (' main '), foreach ($main as $main) {$list = $main Getelementsbytagname_r ("list"), foreach ($list as $list) {$value = $list->firstchild->nodevalue;echo $value. "
";}}? >cy.php output is: 123456 why
7
8
9
7,8,9 is not read? Because our cy.php only read
The contents of the tag.
The content in the tag is not read. The "tag" we refer to here is called "node" in XML; Note: $xml->load (' cy.xml '); load XML file $xml->loadxml (' Cy.xml '); Load a string in XML format