I know this is an old post but just in case anyone is searching...
string myNS =
"http://mydomain.com/URL";
string xsiNamespace =
"http://www.w3.org/2001/XMLSchema-instance";
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0",
"UTF-8", string.Empty));
XmlNode root =
doc.AppendChild(doc.CreateElement("TestRoot",
myNS));
// adding the custom xmlns attribute... the URL on the next line is
CRITICAL!
XmlAttribute attr = doc.CreateAttribute("xmlns",
"xsi", "http://www.w3.org/2000/xmlns/");
attr.InnerText = xsiNamespace;
root.Attributes.Append(attr);
attr = doc.CreateAttribute("schemaLocation",
xsiNamespace);
attr.InnerText =
string.Format(@"{0}/SaleComparableSearchCriteria.xsd",
myNS);
root.Attributes.Append(attr);
XmlNode spNode =
root.AppendChild(doc.CreateElement("SubjectPropert y",
myNS));
XmlElement elSP = doc.CreateElement("Latitude",
myNS);
elSP.SetAttribute("nil", xsiNamespace,
"true");
spNode.AppendChild(elSP);
...
hope this helps.
Fred
Daniel D.C. [MSFT]wrote:
"]Sorry for the late reply. This error happens when the code is
trying to add a namespace attribute and has a mistmatched namespace for the xmlns
"prefix" (i.e. not giving "http://www.w3.org/2000/xmlns/" as the namespace
for the xmlns attribute / namespace node).
However the code fragment you gave in your first post works fine, so
I am at loss why this error occurs. Perhaps, some other part of the code
executes a SetAttribute for a namepsace element without giving the
"http://www.w3.org/2000/xmlns/" string for the namespace parameter
?
--
Daniel D.C. [MSFT]
This posting is provided "AS IS" with no warranties, and confers no
rights
"Joost News" <jo*******@hotmail.com> wrote in message
news:eA*************@TK2MSFTNGP11.phx.gbl...
The error message is "The namespace declaration attribute has an
incorrect namespaceURI: http://www.my.org/MYSchema_1_1."
Joost
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for
it![/quote:c718b05641][code:1:c718b05641][/code:1:c718b05641]