Use PHP5.0 to easily parse XML documents (6)

Source: Internet
Author: User
Use PHP5.0 to easily parse the XML document (6). The following describes how to use the createNode () function to add products, the added result is displayed. <br/> <PRE> <br/> <? The following describes how to add a product using the createNode () function in xmlve, and then displays the added result.


<? Xml version = "1.0" encoding = "GB2312"?> <Shop> <name> Hualian </name> <address> No. 9999, Chang'an Street, Beijing </address> <desc> supermarket chains </desc> <telphone> 123456789 </telphone> <cat id = "food"> <goods id = "food11"> <name> food11 </name> <price> 12.90 </price> <leaveword author = "hahahawen" date = "2004-12-05"> This product is good </leaveword> </goods> <goods id = "food12"> <name> new food12 </name> <price> 22.10 </price> </goods> <goods id = "food13"> <name> food13 </name> <price> 100 </price> </goods> </cat> <cat> <goods id = "tel21"> <name> tel21 </name> <price> 1290 </price> </goods> </cat> <cat id = "coat"> <goods id = "coat31"> <name> coat31 </name> <price> 112 </price> </goods> <goods id = "coat32"> <name> coat32 </name> <price> 45 </price> </goods> </cat> <special id = "hot"> <goods> <name> hot41 </name> <price> 99 </price> </goods> </special> </shop>

The removeNode () function is used to delete a product and the deleted result is displayed.

<? Xml version = "1.0" encoding = "GB2312"?> <Shop> <name> Hualian </name> <address> No. 9999, Chang'an Street, Beijing </address> <desc> supermarket chains </desc> <telphone> 123456789 </telphone> <cat id = "food"> <goods id = "food11"> <name> food11 </name> <price> 12.90 </price> <leaveword author = "hahahawen" date = "2004-12-05"> This product is good </leaveword> </goods> <goods id = "food13"> <name> food13 </name> <price> 100 </price> </goods> </cat> <goods id = "tel21"> <name> tel21 </name> <price> 1290 </price> </goods> </cat> <cat id = "coat"> <goods id = "coat31"> <name> coat31 </name> <price> 112 </price> </goods> <goods id = "coat32"> <name> coat32 </name> <price> 45 </price> </goods> </cat> <special id = "hot"> <goods> <name> hot41 </name> <price> 99 </price> </goods> </special> </shop>

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.