Re: XML - Find and replace text



On Sep 19, 10:52 am, schl...@xxxxxxxxxxxxxxxx wrote:
gcg...@xxxxxxxxx wrote:
On Sep 19, 10:48 am, gcg...@xxxxxxxxx wrote:
What would be the cleanest way to parse an XML file and replace
certain pieces of text that match a specified pattern? I'm going to
know the exact "location" as in the text is always going to be at:

<a>
<b>
<c=stuff>text to replace here</c></b></a>

Any help is appreciated!

I'm using ActiveTcl if that makes any difference.

Cleanest is probably using XSLT with the tdom package.

Michael

OK, so assuming the XML structure is:

<install>
<service>
...
</service>
<service>
<url>
<data name="config1>this is what I want to change</data>
</url>
</service>
</install>

How do I set the value in <data name=config1>. This is what I have so
far.

package require tdom

set fp [open "config.xml" r]
set xml [read $fp]

set doc [dom parse $xml]
set root [$doc documentElement]

Thank you again!

.



Relevant Pages

  • Re: multiple siblings, using tDOM to generate XML
    ... A simple way to generate XML is the following: ... proc map { ... return [string map $mapTEXT2XML $str] ... set doc ...
    (comp.lang.tcl)
  • Re: Rounding error while saving a recordset as XML
    ... I am facing one rounding error while saving a recordset as XML. ... The only fractions that are exact in base 10 are multiples of powers of 1/5 ...
    (microsoft.public.data.ado)
  • Re: lisp and security
    ... gNOSPAMat@jpl.nasa.gov (Erann Gat) wrote: ... > XML, which ... > the exact ... >> Go back to the original post. ...
    (comp.lang.lisp)
  • Re: lisp and security
    ... the exact ... Just because other approaches may encounter the same problem ... > about using Lisp S-Expressions versus XML, and the claim was that this ...
    (comp.lang.lisp)
  • Re: parsing xml file contents
    ... I am trying to write a script for parsing the xml content below: ... set doc ... Also to some useful tutorials on tdom package. ...
    (comp.lang.tcl)