[XML-SIG] replacing parts of xml using xpath

Uche Ogbuji uche.ogbuji at fourthought.com
Sun Sep 12 06:52:11 CEST 2004

On Thu, 2004-09-09 at 06:01, Colin Gillespie wrote:
> Dear All,
> Problem:
> Example xml file:
> <aaa>
> 	<bbb />
> 	<bbb />
> <aaa>
> I want to replace a part of the xml file, identified by an xpath
> construct with something else. For example, 
> replace //bbb[2] with <ccc />
> To get 
> <aaa>
> 	<bbb />
> 	<ccc />
> <aaa>
> Is this possible with pyxml & xpath? If not, can anyone suggest what
> would be the best way to tackling this problem.

Sure you can do this with pyxml and xpath.  I personally would probably
use XUpdate if I had many such types of replacements to do.

Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Meet me at XMLOpen Sept 21-23 2004, Cambridge, UK.  http://xmlopen.org

A hands-on introduction to ISO Schematron - http://www-106.ibm.com/developerworks/edu/x-dw-xschematron-i.html
Wrestling HTML (using Python) - http://www.xml.com/pub/a/2004/09/08/pyxml.html
XML circles the globe - http://www.javareport.com/article.asp?id=9797
Element structures for names and addresses - http://www.ibm.com/developerworks/xml/library/x-elemdes.html
Commentary on "Objects. Encapsulation. XML?" - http://www.adtmag.com/article.asp?id=9090
Harold's Effective XML - http://www.ibm.com/developerworks/xml/library/x-think25.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/

More information about the XML-SIG mailing list