Can anyone tell me what i’m doing wrong here.I am trying to generate a system info in xml.My XML schema is like this
<root>
<system>
<applications>
</applications>
</system>
</root>
Snooping around the internet i found this code.But it is hard to implement it
problems faced:
“b” is a string which i get from regedit.exe’s version number
writer.WriteElementString("Execute Bit Length", "64");
Also doesn’t work
writer.WriteStartElement(".Net Framework 4", NET_FRAMEWORK.ToString());
gives me the error cannot write hexadecimal value 0x20
NET_FRAMEWORK is a boolean value.
Basically i screwed up with the XML
using (XmlWriter writer = XmlWriter.Create("sys_info.xml"))
{
writer.WriteStartDocument();
writer.WriteStartElement("System");
writer.WriteStartElement("OS");
writer.WriteElementString("Ver", Environment.OSVersion.ToString());
writer.WriteElementString("Execute Bit Length", "64");
writer.WriteElementString("Registry version", b.ToString());
writer.WriteEndElement();
writer.WriteStartElement("APPCHECK");
writer.WriteStartElement(".Net Framework 4", NET_FRAMEWORK.ToString());
writer.WriteStartElement("PDF reader", PDF_READ.ToString());
writer.WriteStartElement("internet Explorer Version", IE.ToString());
writer.WriteEndElement();
writer.WriteEndDocument();
Note that spaces are not allowed in XML node names, so you need to change or remove them.
Also I would recommend you to try Linq to XML: