Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

axLW

Programmer
Feb 6, 2015
110
0
0
GB
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=""[URL unfurl="true"]http://www.w3.org/2003/05/soap-envelope""[/URL] "
stringXML = stringXML & "xmlns:SOAPENC=""[URL unfurl="true"]http://www.w3.org/2003/05/soap-encoding""[/URL] "
stringXML = stringXML & "xmlns:xsi=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"""[/URL]
stringXML = stringXML & "xmlns:xsd=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"">"[/URL]
stringXML = stringXML & "<SOAPENV:Body>"
stringXML = stringXML & "<MyTag>Line break ### test</MyTag>"

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

httpRequest.Open "POST", "[URL unfurl="true"]http://MyServer.com",[/URL] 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?
 
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)

 
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
 
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[
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
 
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...


 
Code:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top