Xml, tag: modify the content of a tag specified by XML: modifying the content of a tag specified by Xml (I want to remove the space of the content of the tag) is actually a very simple method. you need to take it directly. Test.xmlrecord blog is a good example of using www.cnblogs.comkeerdip5465549.html to remove XM to modify the Xml specified tag content (I am removing spaces for the specified tag content)
In fact, it is a very simple method, and you need to take it directly.
Test. xml
Recording blogs is a good habit.
Http://www.cnblogs.com/keerdi/p/5465549.html
Remove XML spaces
It is very important to develop a good habit. this is the content of an empty file,
Let's write a blog together.
Http://www.cnblogs.com/keerdi/p/5465549.html
Blog writing can enhance memory
Generally, the installed linux system has an English interface. I checked all the statements on the internet. I only made the following configuration and downloaded a Chinese package, it's not that complicated to change i18 n.
Update. php
Load ($ xmlpath); $ root = $ xml-> documentElement; // obtain the total number of tags $ nodes = $ root-> getElementsByTagName ("item "); for ($ I = 0; $ I <= $ nodes-> length; $ I ++) {// specify the content tag and obtain the content tag content through delTrim () remove all spaces $ str = $ xml-> getElementsByTagName ("content")-> item ($ I ); // $ str-> nodeValue = "the content to be modified"; $ str-> nodeValue = $ this-> delTrim ($ str-> nodeValue ); $ xml-> save ("test. xml ") ;}}// delete space function delTrim ($ object) {$ search = arra Y ("", "", "\ t", "\ n", "\ r"); $ replace = array ("","","", "", ""); returnstr_replace ($ search, $ replace, $ object) ;}?>
The preceding section describes how to modify the specified tag in XML, including xml and tag content, and hopes to help users who are interested in PHP tutorials.