Please Help String Problem

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Hello,

I am having a problem with a multiline string that I create from a byte
array (xml file). I am using StringBuilder and Ecoding the string to ASCII
(code below).

/ Upload the NameValueCollection.
byte[] responseArray =
myWebClient.UploadValues(xmlParser.GetXMLValue(nodePath + "RequestURL",
"requesturl"), "POST", myNameValueCollection);
// used to build entire input
StringBuilder sb = new StringBuilder();
string tempString = null;
string response = "";
tempString = Encoding.ASCII.GetString(responseArray);
sb.Append(tempString);
response = sb.ToString();

The response still is multi-line with the xml being cut off in elements.
Example:
..... <no
de1/>..... <element1>te
<element1/>

I have tried this code to remove carraige returns, new lines...
response = response.Replace("\r", "").Replace("\t", "").Replace("\n", "");
It removes these characters in the string but leaves the fragmented xml
string.
Any ideas?
 
Fred,
What is "xmlParser.GetXmlValue"? Doesn't sound like anything from the .NET
Framework.
Try loading the document into an XmlDocument class instance, and see if it
is actually well-formed XML. Alternatively, you can try changing the encoding
to UTF8.
Peter
 
Peter,

You are correct that xmlParser.GetXmlValue is not part of .net. It is a
part of my assembly that retrieves the url of the form I am posting to.
However, I have tried UTF8 with no luck and have used Regex too. The
problem is the app I am posting to is returning a formatted xml and when I
the byte array to a string the string gets fragmented. I need to store it
as a string however is there a way to convert the initial byte array into a
xml document? Or do you have an other ideas?

Thanks

Peter Bromberg said:
Fred,
What is "xmlParser.GetXmlValue"? Doesn't sound like anything from the .NET
Framework.
Try loading the document into an XmlDocument class instance, and see if it
is actually well-formed XML. Alternatively, you can try changing the
encoding
to UTF8.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Fred said:
Hello,

I am having a problem with a multiline string that I create from a byte
array (xml file). I am using StringBuilder and Ecoding the string to
ASCII
(code below).

/ Upload the NameValueCollection.
byte[] responseArray =
myWebClient.UploadValues(xmlParser.GetXMLValue(nodePath + "RequestURL",
"requesturl"), "POST", myNameValueCollection);
// used to build entire input
StringBuilder sb = new StringBuilder();
string tempString = null;
string response = "";
tempString = Encoding.ASCII.GetString(responseArray);
sb.Append(tempString);
response = sb.ToString();

The response still is multi-line with the xml being cut off in elements.
Example:
..... <no
de1/>..... <element1>te
<element1/>

I have tried this code to remove carraige returns, new lines...
response = response.Replace("\r", "").Replace("\t", "").Replace("\n",
"");
It removes these characters in the string but leaves the fragmented xml
string.
Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top