Writing namespace to an XML stream

    Date: 02/11/09 (C Sharp)    Keywords: html, xml

    I'm trying to write XHTML to an XmlWriter. I'm having trouble generating the standard line:
    http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

    With "writer" as my XmlWriter I have
    writer.WriteStartElement("html");
    writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");
    writer.WriteAttributeString("lang", "en");
    writer.WriteAttributeString("xml:lang", "en");

    but writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml") generates an XmlException: "The prefix '' cannot be redefined from '' to 'http://www.w3.org/1999/xhtml' within the same start element tag."

    What am I missing? How do I get that namespace defined?

    TIA.

    Source: https://csharp.livejournal.com/101629.html

« My open source project || It's the newest post


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home