how to create xml file in c#
new XDocument(
new XElement("root",
new XElement("someNode", "someValue")
)
)
.Save("foo.xml");
how to create xml file in c#
new XDocument(
new XElement("root",
new XElement("someNode", "someValue")
)
)
.Save("foo.xml");
how to create xml file in c#
private XmlElement CreateLicenseKeyValuePairNodes(XmlDocument document)
{
XmlElement keyValueElement = document.CreateElement("KeyValuePair");
XmlElement keyElement = document.CreateElement("Key");
XmlElement valueElement = document.CreateElement("Value");
keyValueElement.AppendChild(keyElement);
keyValueElement.AppendChild(valueElement);
return keyValueElement;
}
protected virtual void CreateXmlDoc(int count)
{
XmlDocument outputDocument = new XmlDocument();
XmlElement rootElement = outputDocument.CreateElement("Base");
XmlElement customerElement = outputDocument.CreateElement("Customer");
XmlElement projectElement = outputDocument.CreateElement("Project");
XmlElement programIdElement = outputDocument.CreateElement("ProgramID");
XmlElement activationIdElement = outputDocument.CreateElement("ActivationID");
XmlElement featureElement = outputDocument.CreateElement("Features");
XmlElement releaseElement = outputDocument.CreateElement("ReleaseDate");
XmlElement validationElement = outputDocument.CreateElement("ValidUntil");
rootElement.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
rootElement.SetAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
rootElement.AppendChild(customerElement);
rootElement.AppendChild(projectElement);
rootElement.AppendChild(programIdElement);
rootElement.AppendChild(activationIdElement);
rootElement.AppendChild(featureElement);
for (int i = 0; i < count; i++)
{
featureElement.AppendChild(CreateLicenseKeyValuePairNodes(outputDocument));
}
rootElement.AppendChild(releaseElement);
rootElement.AppendChild(validationElement);
outputDocument.AppendChild(rootElement);
outputDocument.Save(@".\Template.xml");
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us