Any HTML code here
My name is so value2 value3 value4
Test value
value 1 value2
value4
EOT; $dom = new DomDocument; $dom->preservewhitespace = FALSE; $dom->loadxml ($xml); $params = $dom getElementsByTagName (' section '); Find Sections $k =0;foreach ($params as $param)//go to each of the sections 1 by 1 {echo ' section Attribute:-> '. $ Params->item ($k)->getattribute (' name '). "
"; Get section attribute $params 2 = $params->item ($k)->getelementsbytagname (' category '); Digg categories with $i = 0; Values are used to iterate categories foreach ($params 2 as $p) {echo "-Category Attribute Name:- > ". $params 2->item ($i)->getattribute (' name ')."
"; Get Category attributes $params 3 = $params 2->item ($i)->getelementsbytagname (' Arti '); Dig Arti into Categories $j =0;//values used to Interate Arti foreach ($params 3 as $p 2) {echo "-article Attribute Name:". $params 3->item ($j)->getattribute (' NA Me '). ""; Get Arti Atributesecho "Value:". $params 3->item ($j)->nodevalue. "
"; Get Node value; $j + +; } $i + +; } $k + +; }?>output:section Attribute:-> section1-category Attribute Name:-> google-article Attribute N Ame:article1 value:any HTML code heremy name is so so-article Attribute name:article2 Value:value 2-article Attribute name:article3 value:value3-article Attribute name:article4 Value: Value4-category Attribute Name:-> yahoo-article Attribute name:articlesection2 value:test Value Section Attribute:-> section2-category Attribute Name:-> msn-article Attribute name:article2 V Alue:value1-article Attribute name:article3 value:value2-category Attribute Name:-> webcare -Article Attribute name:param3 value:value4
Excerpt: Php.net