Dave wrote:
you can write
writer.WriteStartElement("data", "http://www.w3.org/1999/XMLSchema-instance");
in your code for,
<data xmlns="http://www.w3.org/1999/XMLSchema-instance">
how do you write,
<data xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../documents/xml/epic.xsd">
for two attributes?
Note that the official W3C schema instance URI is
http://www.w3.org/2001/XMLSchema-instance.
As for writing attributes, in case of a namespace declaration like
xmlns:xsi="..." you don't need to write it at all, it suffices to write
the attribute in that namespace:
const string xsi = "http://www.w3.org/2001/XMLSchema-instance";
using (XmlWriter writer = XmlWriter.Create(Console.Out))
{
writer.WriteStartElement("data");
writer.WriteAttributeString("xsi",
"noNamespaceSchemaLocation", xsi, "../documents/xml/epic.xsd");
writer.WriteEndElement();
}
If you want to explicitly write the namespace declaration, then that is
possible too:
const string xsi = "http://www.w3.org/2001/XMLSchema-instance";
using (XmlWriter writer = XmlWriter.Create(Console.Out))
{
writer.WriteStartElement("data");
writer.WriteAttributeString("xmlns", "xsi",
"http://www.w3.org/2000/xmlns/", xsi);
writer.WriteAttributeString("xsi",
"noNamespaceSchemaLocation", xsi, "../documents/xml/epic.xsd");
writer.WriteEndElement();
}
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/