Update attributes in existing XML document

  • Thread starter Thread starter daz_oldham
  • Start date Start date
D

daz_oldham

Hi Everyone

I was wondering if anyone could help me out with fairly
straightforwards problem I have.

I have an XML document (in a namespace) and I would like to loop around
one level of the child nodes, and insert a new value to each node. It
needs to be fairly efficient too.

I guess this isn't too difficult to do, but I haven't got a clue how to
do it!

Many thanks in advance

Daz

Example:

<chairs>
<chair id="1" type="1">
<chair id="2" type="1">
</chairs>

To:

<chairs>
<chair id="1" type="1" newvalue="x">
<chair id="2" type="1" newvalue="y">
</chairs>
 
daz_oldham said:
Hi Everyone

I [wanna change]:

<chairs>
<chair id="1" type="1">
<chair id="2" type="1">
</chairs>

To:

<chairs>
<chair id="1" type="1" newvalue="x">
<chair id="2" type="1" newvalue="y">
</chairs>

Have a look at XSLT. It is well suited for such transformations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top