User1216489373 posted
Hi Experts,
I want to append new node in already existing XML. My XML structure is as follows:-
<NewDataSet>
<Table>
<HotelName>A</HotelName>
<Rating>5*</Rating>
<Hzone>Central </Hzone>
<HBeds>B</HBeds>
<Address>Lodhi Road</Address>
<Soh>-</Soh>
<Recommended>0</Recommended>
<DetailStr>-</DetailStr>
<Block>N</Block>
</Table>
<Table>
<HotelName>B</HotelName>
<Rating>5*</Rating>
<Hzone>Central </Hzone>
<HBeds>A</HBeds>
<Address>Lodhi Road</Address>
<Soh>Bh</Soh>
<Recommended>0</Recommended>
<DetailStr>-</DetailStr>
<Block>N</Block>
</Table>
<NewDataSet>
I want to add <HId> node after <Block> Tag i.e. I want my XML as
<NewDataSet>
<Table>
<HotelName>A</HotelName>
<Rating>5*</Rating>
<Hzone>Central </Hzone>
<Address>Lodhi Road</Address>
<HBeds>A</HBeds>
<Soh>-</Soh>
<Recommended>0</Recommended>
<DetailStr>-</DetailStr>
<Block>N</Block>
<HId>1</HId>
</Table>
<Table>
<HotelName>B</HotelName>
<Rating>5*</Rating>
<Hzone>Central </Hzone>
<Address>Lodhi Road</Address>
<HBeds>B</HBeds>
<Soh>Bh</Soh>
<Recommended>0</Recommended>
<DetailStr>-</DetailStr>
<Block>N</Block>
<HId>2</HId>
</Table>
<NewDataSet>
I am getting the value of HId from Database using following code.
Dim XmlNodeListPackes As XmlNodeList
XmlNodeListPackes = xDoc.SelectNodes("/NewDataSet/Table")
For Each xNode As XmlNode In XmlNodeListPackes
Dim strHotelBeds As String = xNode.SelectSingleNode("Hbeds").InnerText
Dim City As String = txtxmlfile.Text
HId = DAL.GetHotelBedId(strHotelBeds, City)
Next
I want to insert this HId in XML. Please help me with the code.
Thanks,
Rahul