INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Line Break in XML String (Classic ASP HTTP Post) for Windows

Line Break in XML String (Classic ASP HTTP Post) for Windows

(OP)
We have an 'off the shelf' Windows Application.

I'm using Classic ASP to post an XML string to my database and trying to induce a line break (to be seen in the Windows Application itself).

CODE

<%@ language="vbscript" codepage="65001"%>

stringXML = "<?xml version=""1.0"" encoding=""UTF-8""?>"
stringXML = stringXML & "<SOAPENV:Envelope "
stringXML = stringXML & "xmlns:SOAPENV=""http://www.w3.org/2003/05/soap-envelope"" "
stringXML = stringXML & "xmlns:SOAPENC=""http://www.w3.org/2003/05/soap-encoding"" "
stringXML = stringXML & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
stringXML = stringXML & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
stringXML = stringXML & "<SOAPENV:Body>"
stringXML = stringXML & "<MyTag>Line break ### test</MyTag>"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")

httpRequest.Open "POST", "http://MyServer.com", False
httpRequest.SetRequestHeader "Content-Type", "text/xml"
httpRequest.SetRequestHeader "Content-Length", Len(stringXML)
httpRequest.Send stringXML 

1. I have tried using \n and also \r\n (inside the string):

CODE

stringXML = stringXML & "<MyTag>Line break \r\n test</MyTag>" 

but they simply appear exactly as they are when viewed in the Application (no line break).


2. I have tried using &#xD; (inside the string):

but this does not induce a line break, it simply displays as a box (□)


3. I have tried vbCrLf

CODE

stringXML = stringXML & "<MyTag>Line break " & vbCrLf & "test</MyTag>" 

but this doesn't actually seem to do anything (has no effect).



4. I have also tried using CDATA which I know nothing about...

CODE

stringXML = stringXML & "<MyTag><![CDATA[Line break <br> test]]></MyTag>" 

but this just places <br> or <br /> in the string (no line break).


Does anybody have any other suggestions?

RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

(OP)
I have also tried escaping the backslash like so:

&#92;n&#92;r

But this simply displays \n\r it doesn't give me a new line.



Tried &#x13&#x10; which is apparently CR + LF

This places the square character in the string (no new line)

RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

(OP)
Any suggestions at all??

RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

Without knowing what "The Application" is and does ... No.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

or you could try;


&#xD; for a carriage return (CR) and &#xA; for a line break/feed (LF)

or use a CDATA element

CODE --> (CDATA)

<![CDATA[
First line of text.                       
Second line of text.
]]> 

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

(OP)
Hello Chris, thanks for the reply.

The software I'm using is Cordic (Taxi Dispatch Software) running on Windows. Screen Shot

I have tried using CDATA like so:

CODE

stringXML = stringXML & "<MyTag><![CDATA[This is a
Line Break]]></MyTag>" 

But because I'm posting the XML message as a string using ASP it breaks the code


Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/sendXML2.asp, line 293

stringXML = stringXML & "<OperatorNotes><![CDATA[This is a
----------------------------------------------------------^



I'm not exactly sure how to carriage return within the CDATA tag but ensure the ASP code still compiles...


RE: Line Break in XML String (Classic ASP HTTP Post) for Windows

CODE --> vbScript

str= "I always use chr(34) to insert a " & chr(34) & "double quote mark" & chr(34) & "." 

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close