Forum Discussion

Mathit's avatar
Mathit
Contributor
6 years ago

Update a node in xml file

My sample xml file looks like this:

<Ratings>
<Rating>
<RatingCode>AAA</RatingCode>
<RatingDesc>AAA</RatingDesc>
</Rating>
<Rating>
<RatingCode>BBB</RatingCode>
<RatingDesc>BBB</RatingDesc>
</Rating>
<Rating>
<RatingCode>CCC</RatingCode>
<RatingDesc>CCC</RatingDesc>
</Rating>
</Ratings>

 

My code looks like this:

Set Doc = Sys.OleObject("Msxml2.DOMDocument.6.0")
Doc.async = False
Call Doc.load(filetoload)
Set Node = Doc.documentElement
Set Nodeval = Doc.selectSingleNode("//Quote/Quotesheets/Ratings/Rating/Ratingcode")
Nodeval.Text = texttoupdate
Call Doc.Save(outputfile1)
Set Doc = Nothing

 

Is there a way to count the no. of children for Ratings and Rating?

Can you please let me know how I can update the second child of Rating.  ie, i want to update the value BBB to XXX