Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
XML
<?xml version="1.0" encoding="UTF-8"?>
  <Authentication username="testuser" password="ECLPASS"/>
  <Hotel id="411"/>
  <AvailRateUpdate>


how to create this type of coad in c#

i can create
XML
<Authentication username="testuser" password="ECLPASS"/> this line but add new noad hotel  then it can be inside of  
<authentication username="testuser" password="ECLPASS">
  <hotel id="411" />
  </authentication>

How to solve this
or how to create hotelid after the authentication completes


my code below
  XmlTextWriter writer = new XmlTextWriter(Server.MapPath ("product.xml"), System.Text.Encoding.UTF8);
        XmlDocument doc = new XmlDocument();
        writer.WriteStartDocument(true);
        writer.Formatting = Formatting.Indented;
        XmlNode AuthenticationNode = doc.CreateElement("Authentication");
        XmlAttribute UserName = doc.CreateAttribute("id");
        UserName.Value = "eqcuser";
        XmlAttribute password = doc.CreateAttribute("Password");
        password.Value = "eqcpass";
        AuthenticationNode.Attributes.Append(UserName);
        AuthenticationNode.Attributes.Append(password);
        doc.AppendChild(AuthenticationNode);

        XmlNode root = doc.CreateElement("Hotel");
        XmlAttribute  HotelNode = doc.CreateAttribute("Id");
        HotelNode.Value = "36972";
        root.Attributes.Append(HotelNode);
        doc.AppendChild(root);
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900