Hello
I'm using c# XmlDocument class to add new XHTML-Nodes to my website.
Unfortunately XmlDocument always adds an unwanted empty namespace attribute
xmlns="" to every new Element.
These empty namespace attributes cause that the elements are'nt found any
more when I'm reparsing the document. (When I delete them by hand everything
works fine).
This is really stupid. DotNet XML-classes aren't very useful for me if I
can't affect their behaviour.
XmlSerializer seems to have the same problem.
Isn't there any hack to bypass the blank namespaces???
Thank you
Sincerely
Lore
******************* code ***************************
//doc is a loaded XmlDocument object
XmlElement paragraph = doc.CreateElement("p");
paragraph.SetAttribute("class","paragraph");
XmlElement imgNode = null;
if(pctEntry.Image != null)
{
imgNode = doc.CreateElement("img");
imgNode.SetAttribute("src",pctEntry.Tag.ToString() );
imgNode.SetAttribute("alt",txtAlt.Text);
paragraph.AppendChild(imgNode);
}
//text
if(txtEntry.Text.Trim() != "")
{
string tmp = ToXHTML(txtEntry.Text);
XmlText textNode = doc.CreateTextNode(tmp);
paragraph.AppendChild(textNode);
}
XmlNode node = doc.SelectSingleNode("//xl:div[@ id='content']",
namespaceManager);
if(node != null)
node.AppendChild(paragraph);