Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Create XML file usign C# and then create sub node in existing file

Tags: node
 string file = @"c:\bb.xml";  
// declearation
// parent node

XmlElement subnode = xdoc.CreateElement("subnode");
// Checking File Exist or not
if (File.Exists(file))
{
xdoc.Load(@"C:\bb.xml");
xdoc.DocumentElement.AppendChild(userinfo(txtuser.Text, txtpass.Text));
xdoc.Save(file);
}
else
{
subnode.AppendChild(userinfo(txtuser.Text, txtpass.Text));
xdoc.AppendChild(subnode);
xdoc.InsertBefore(xdoc.CreateXmlDeclaration("1.0", "utf-8", null), subnode);
xdoc.Save(file);
}


// then create the xml node using this methods


XmlNode node = xdoc.CreateElement("Info");
XmlNode user_node = xdoc.CreateElement("user");
user_node.InnerText = user.ToString();
node.AppendChild(user_node);
XmlNode pass_node = xdoc.CreateElement("password");
pass_node.InnerText = pass;
node.AppendChild(pass_node);
return node;


This post first appeared on News About SEO, please read the originial post: here

Share the post

Create XML file usign C# and then create sub node in existing file

×

Subscribe to News About Seo

Get updates delivered right to your inbox!

Thank you for your subscription

×