How to wrtie a XML License Line(ended with a forward slash '/') in C#?

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-03-25T09:08:57Z Indexed on 2010/03/25 9:23 UTC
Read the original article Hit count: 339

Filed under:
|
|

I want to write a XML file as below:

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <License licenseId="" licensePath="" />

Some piece of my code attached here

    // Create a new file in D:\\ and set the encoding to UTF-8
    XmlTextWriter textWriter = new XmlTextWriter("D:\\books.xml", System.Text.Encoding.UTF8);

    // Format automatically
    textWriter.Formatting = Formatting.Indented;

    // Opens the document
    textWriter.WriteStartDocument();

    // Write the namespace declaration.
    textWriter.WriteStartElement("books", null);
    // Write the genre attribute.
    textWriter.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
    textWriter.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");

And now I need to write the License Line below in C#

<License licenseId="" licensePath="" />

But I don't know how to move on for I found the Line ended with the forward slash / .Thank you.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml