Modify the content of the specified tag in XML c # obtain the tag c # xml null tag in the xml node Tencent qqxml message tag

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.