cancel
Showing results for 
Search instead for 
Did you mean: 

Update a node in xml file

Highlighted
Contributor

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

1 REPLY 1
Highlighted
Community Hero

Re: Update a node in xml file

Hi,

 

https://stackoverflow.com/questions/7448232/vbscript-select-multiple-xml-nodes-that-use-a-self-closi...

https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmlnode.selectnodes?view=netframework-4.7.2

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754523(v%3Dvs.85)

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors