Click to See Complete Forum and Search --> : .NET System.Xml exception returns "Cannot use a prefix with an empty namespace"


psgg1981
03-16-2004, 09:24 AM
I'm building an xml document with XML Document Object Model (DOM) with System.Xml library in .NET.

It seems that when validating the document the XmlDocument class (which implements the DOM) detects a syntax error. Then I get this exception info: "Cannot use a prefix with an empty namespace"

While debugging, I checked the actual Xml document encapsulated in the XmlDocument class. It looks like this (don't mind the escape characters):

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">
<s:Body>
<u:SetTarget xmlns:u=\"urn:schemas-upnp-org:service:SwitchPower:1\">
<newTargetValue>1</newTargetValue>
</u:SetTarget>
</s:Body>
</s:Envelope>

My immediate question is: does the Body element require an xmlns namespace since it uses the same as its parent, Envelope?