Work in xml file with php [closed]

mykes_

New Member
Possible Duplicate:
A simple program to CRUD node and node values of xml file I would like to change some data in a xml file with php.So in my xml file I have this : <items><item href="http://stackoverflow.com/questions/11137248/p002.xhtml" id="p002" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b002.jpg" id="b002" media-type="image/jpeg"/> <item href="http://stackoverflow.com/questions/11137248/p003.xhtml" id="p003" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b003.jpg" id="b003" media-type="image/jpeg"/> <item href="http://stackoverflow.com/questions/11137248/p004.xhtml" id="p004" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b004.jpg" id="b004" media-type="image/jpeg"/> <item href="http://stackoverflow.com/questions/11137248/p005.xhtml" id="p005" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b005.jpg" id="b005" media-type="image/jpeg"/></items>I would like to open the file, delete all item greater than 0003 and save changes. I have some tags between this extract.Result: <items><item href="http://stackoverflow.com/questions/11137248/p002.xhtml" id="p002" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b002.jpg" id="b002" media-type="image/jpeg"/> <item href="http://stackoverflow.com/questions/11137248/p003.xhtml" id="p003" media-type="application/xhtml+xml"/> <item href="http://stackoverflow.com/questions/11137248/img/b003.jpg" id="b003" media-type="image/jpeg"/></items>Thank for your help an idea!Trying :if( ! $xml = simplexml_load_file("pack.xml") ) { echo 'unable to load XML file'; } else { echo "<ul>"; foreach($xml->items->item as $v ){ //echo "<li>".$v[href]."</li>"; if($v[href]=="p003.xhtml" || $v[href]=="img/bg003.jpg"){ echo "<li>".$v[href]."</li>"; } }echo "</ul>";} How to check the greater than p003.xhtml and img/bg003.jpg ?
 
Back
Top