[Mono-list] Questions about writing an XML document
lorenb at mmgsecurity.com
Tue May 9 07:30:53 EDT 2006
I want to write an XML document but there are some parts I'm not sure
how to go about doing. Specifically namespaces and schemas. Take the
following example XML:
<?xml version="1.0" encoding="UTF-8"?>
To create it, I've tried doing something like this:
XmlDocument xmlDoc = new XmlDocument ();
XmlElement docElement = xmlDoc.CreateElement ("doc");
docElement.SetAttribute ("xmlns", "http://whatever.org/XMLSchema/foo");
XmlElement fooElement = xmlDoc.CreateElement ("foo");
This just fails with an ArguementException saying "Cannot use prefix
with an empty namespace". That kind of tells me I'm not going in the
right direction but I haven't had luck finding any proper examples.
I've seen the XmlNamespaceManager class and tried to use it. I can add
namespaces but when I write out the document, they are not listed at
If anyone has any suggestions that would be great.
Loren Bandiera <lorenb at mmgsecurity.com>
MMG Security, Inc.
More information about the Mono-list