Code:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Project DefaultTargets='Build' xmlns='http://schemas.microsoft.com/developer/msbuild/2003\'></Project>".Replace("'", "\x22"));
XmlNode node = doc.CreateElement("Proba");
doc.DocumentElement.AppendChild(node);
Console.WriteLine("Attributes: " + node.Attributes.Count);
Console.WriteLine("node.OuterXml: " + node.OuterXml);
Console.WriteLine(doc.OuterXml);
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Project DefaultTargets='Build' xmlns='http://schemas.microsoft.com/developer/msbuild/2003\'></Project>".Replace("'", "\x22"));
XmlNode node = doc.CreateElement("Proba");
doc.DocumentElement.AppendChild(node);
Console.WriteLine("Attributes: " + node.Attributes.Count);
Console.WriteLine("node.OuterXml: " + node.OuterXml);
Console.WriteLine(doc.OuterXml);
daje sledeci rezultat:
Code:
Attributes: 0
node.OuterXml: <Proba />
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Proba xmlns="" /></Project>
Attributes: 0
node.OuterXml: <Proba />
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Proba xmlns="" /></Project>
Moj problem je sto mi je u node Proba dodao atribut xmlns="".
node.Attributes.Count kaze da nema atributa a i node.OuterXml ne daje taj xmlns pa pretpostavlja da je nesto do generisanja dokumenta ali ne znam gde.
Znam da se ovo moze ukoniti kada bi uklonio i xmlns iz root-a ali mi on treba.