Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dealing with empty string in .InnerText problem
Message
Information générale
Forum:
ASP.NET
Catégorie:
XML
Divers
Thread ID:
00894839
Message ID:
00894880
Vues:
8
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform