Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dealing with empty string in .InnerText problem
Message
General information
Forum:
ASP.NET
Category:
XML
Miscellaneous
Thread ID:
00894839
Message ID:
00894880
Views:
9
The other thing to look at is how are you serializing the infoset? The default XmlDocument.Save method will format the xml using indenting. You can change the behavior by setting the Formatting property of the XmlTextWriter to None.
...
XmlTextWriter xw = new XmlTextWriter(Console.Out); //substitute the name of your file here
xw.Formatting = Formatting.None;
oXml.Save(xw);
>Will
>
>oChild.IsEmpty = true;
>
>
>do what you want? It will produce
>
><Fld name="REQUESTOR" />
>
>
>>The following is a segment of code that adds a node to an XML document:
>>
>>
>>oChild = oXml.CreateElement("Fld");
>>oChild.InnerText = "";
>>oAttr = oXml.CreateAttribute("name");
>>oAttr.Value = "REQUESTOR";
>>oChild.Attributes.SetNamedItem(oAttr);
>>oRoot.AppendChild(oChild);
>>
>>
>>Even though .InnerText is empty string, the node in XML file looks like this:
>>
>>
>><Fld name="REQUESTOR">
>></Fld>
>>
>>
>>And when I programatically extract the value from the XML file, it contains:
>>chr(13)Chr(10)and then bunch of chr(32)
>>
>>Instead, I would expect it to be:
>>
>>
>><Fld name="REQUESTOR"></Fld>
>>
>>
>>Why does .net insert CR and bunch of empty characters when InnerText should be empty string?
>>
>>Thank you.
Previous
Reply
Map
View

Click here to load this message in the networking platform