XPathNavigatore removing carriage returns from the string


hi

we using xpathdocument , xpathnavigator read in memory string contains carriage returns , line feeds.

say example: "my string starts here\r\n here next line\r\n" converted "my string starts here\n here next line\n"

is there setting on these classes not remove carriage returns?

here sample code

strings = "<args><arg name=\"p1\" type=\"string\">p1data</arg>\r\n  <arg name=\"p2\" type=\"int32\">0</arg>\r\n  <arg name=\"p3\" type=\"string\">my string starts here\r\n here next line\r\n</arg>\r\n  <arg name=\"p4\" type=\"boolean\">false</arg>\r\n</args>";

           

xpathdocumentd = newxpathdocument(xmlreader.create(newstringreader(s)));

           

           

xpathnavigatorn = d.createnavigator();

           

xpathnodeiteratornodes = n.select("/args/arg");

           

foreach(xpathnavigatorargnav innodes)

            {

               

xpathnodeiteratorargnode = argnav.select("./@name");

                argnode.movenext();

               

console.writeline(argnode.current.value);

                argnode = argnav.select(

"./@type");

                argnode.movenext();

               

console.writeline(argnode.current.value);

                argnode.movenext();

               

console.writeline(argnav.value);

            }

for third argument, on debugging, have observed \r got removed

thanks

s


hi pocketpc2012,

there's nothing wrong code.

the receiver of xml treat "\r" white space. need encode "\r" in the inner text of xml "&#xd;". target string "my string starts here&#xd;\n here next line&#xd;\n" work fine.

for more information, please refer following thread:

http://stackoverflow.com/questions/7292407/preserve-carriage-returns-when-i-write-read-from-xml-file-using-asp-net


caillen
msdn community support | feedback us
develop , promote apps in windows store
please remember mark replies answers if , unmark them if provide no help.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'