Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7729205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:54:35+00:00 2026-06-01T05:54:35+00:00

Here is the code I have tried to append a node in existing xml,

  • 0

Here is the code I have tried to append a node in existing xml,

XmlDocument doc = new XmlDocument();
XmlNode root = doc.DocumentElement;
XmlElement elem = doc.CreateElement("price");
doc.LoadXml("<Hotel><OptionNo>1</OptionNo><StayDateRange Start=\"15/04/2012\" End=\"17/04/2012\"/><Property Id=\"31461\" CityCode=\"666\" CityName=\"MUMBAI\" CountryCode=\"246\" CountryName=\"INDIA\" StateCode=\"7332\" StateName=\"Maharashtra\" StarRating=\"1\" Chain=\"\" Status=\"Available\" HotelName=\"Airlines International Hotel\" Preferred=\"Yes\" BuiltYear=\"\" RenovationYear=\"\" NoOfFloors=\"\" Location=\"YOGA INSTITUTE RD,PRABHAT COLONY,SANTACRUZ(E),MUMB  Mumbai\" MinimumRate=\"4733.43\" Currency=\"INR\"><Address><Address1>YOGA INSTITUTE RD,PRABHAT COLONY,SANTACRUZ(E),MUMB  Mumbai</Address1><Address2/><CityCode>666</CityCode><CountryCode>246</CountryCode><PostalCode>400055</PostalCode><CityName>MUMBAI</CityName></Address><Description Name=\"Comprising of 27 rooms in total, this small budget hotel is clean and comfortable, making it the ideal choice for both business and leisure travellers. Fully air-conditioned, it features a 24-hour reception, currency exchange facilities, lift access and an on-site restaurant. Room and laundry services are also available.\" Url=\"\"/><GeoCode Code=\"\" longitude=\"\" latitude=\"\"/><Images><HotelFrontImage Url=\"\"/><Room Url=\"\"/></Images><OtherHotelImages/><Features/><Transportation/><Attractions/></Property><Rooms><Room NumberOfRooms=\"1\" RoomId=\"4511\" Description=\"Double Room\" Twin=\"No\" SupplierCode=\"HP\" SupplierId=\"4\" PropertyId=\"31461\" ExtraBed=\"0\" RateBasis=\"0\" Type=\"Double\"><Rate Id=\"4511\" Currency=\"INR\" Gross=\"9466.86\" Net=\"9466.86\" Tax=\"0\" ExtraGuestCharge=\"0.00\" AdultCount=\"2\" AdultRate=\"\" ChildCount=\"0\" ChildRate=\"\" Description=\"Bed and Breakfast\" Status=\"Available\" AllocationDetails=\"OC-84296147\"><Nights><Night Date=\"1\" Gross=\"4733.43\" Net=\"4733.43\" Tax=\"0.00\" AdultCount=\"2\" AdultRate=\"0\" ChildCount=\"0\" ChildRate=\"0\" ExtraGuestCharge=\"0\" BookedDate=\"15/04/2012\" FreeStay=\"\" RateSupplierId=\"1\" Status=\"Available\"/><Night Date=\"2\" Gross=\"4733.43\" Net=\"4733.43\" Tax=\"0.00\" AdultCount=\"2\" AdultRate=\"0\" ChildCount=\"0\" ChildRate=\"0\" ExtraGuestCharge=\"0\" BookedDate=\"16/04/2012\" FreeStay=\"\" RateSupplierId=\"1\" Status=\"Available\"/></Nights><MinStay/><DateApplyMinStay/><CancellationRules>Please see the cancellation rules</CancellationRules></Rate><Ages/><Amenities/></Room></Rooms></Hotel>");
root = doc.DocumentElement;
elem = doc.CreateElement("OtherHotelImage");
elem.InnerText = "URL";
root.AppendChild(elem);
doc.Save(Console.Out);

I tried to add new node inside the specified xml, which is inside of <OtherHotelImages> element. but it is created inside of root element which is <Hotel>.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:54:36+00:00Added an answer on June 1, 2026 at 5:54 am

    You are calling root.AppendChild()… so yes, it goes in at the root. You need to walk the XML tree until you find the right element – and then add the new element to that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sorry about the amount of code here. I have tried to show
Here's the code I have: from cStringIO import StringIO from lxml import etree xml
enter code here I have a ListView that have a different Layout XML for
enter code here I have a table on SQL server 2005 with bigint primary
Here is the code I have to create an UIAlertView with a textbox. UIAlertView
Here's the code I have: var commandsBuffer = List[String]() commandsBuffer ::= cmd.exe commandsBuffer ::=
I have this code here, which is intended to allow any type of arguments:
I have this code here, {foreach from=$cart.cartItems item=item name=cart} <div id=cart2Produkt> <p>{if $item.Product.ID} <a
I have some code here which works perfectly in firefox but not in chrome
I have seen a similar question, HERE and have tried that, but I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.