spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / php / php4xml / chap10 / 2 current pageTo page 2To page 3To page 4
[next]

Professional PHP4 XML, Chapter 10: Putting It Together

Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow

Modifying XML

[The following is a continuation of our series of excerpts from chapter 10 of the Wrox Press title, Professional PHP4 XML. Source code for the examples discussed can be downloaded at the Wrox Web site (free e-mail registration required).]

Modifying XML is a problem where we have an XML data source and need to modify it. We may want to change some text, add an attribute, add an element, or remove a subtree of the document.

Modifying is a subset of the transforming problem since the output is always XML, and belongs to the same vocabulary as the original file.

Here are some situations where we might find instances of this problem:

Example

For example, let's imagine we use XML to keep track of a shopping cart in some online store application. We may face a simple XML such as:

<cart>
  <user uid="382378">
    <name>John Smith</name>
  </user>
  <products>
    <product pid="12">
      <name>ACMEPencilHB</name>
      <desc>Soft Pencil by ACME</desc>
      <quantity>2</quantity>
      <unit_price>0.50</unit_price>
    </product>

    <product pid="13">
      <name>ACMEPen089</name>
      <desc>Rollerball pen</desc>
      <quantity>1</quantity>
      <unit_price>1</unit_price>
    </product>

  </products>
</cart>

Customers will use an interface to add/remove products from the shopping cart, and we have to reflect those changes to the XML file. Therefore, we'll need a way to:

Of course we should need more functions for our shopping cart to be usable, but let's use only these three for our examples.

When modifying XML is our task, the options are:


home / programming / php / php4xml / chap10 / 2 current pageTo page 2To page 3To page 4
[next]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

Created: August 19, 2002
Revised: August 19, 2002

URL: http://webreference.com/programming/php/php4xml/chap10/2/