Re: Problem with alert and \n in javascript !

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jelmer (jkuperus_at_planet.nl)
Date: 04/14/04


Date: Wed, 14 Apr 2004 13:39:57 +0200

You mean you the xml you retrieve is send over the wire like this?

<root>
    <element>something\nsomething else</element>
</root>

that doesn't work, \n is an escape sequence and that instructs the parser
to replace it with the chosen sequence when it encounters it in program code
in your case your not writing code your retrieving a string , so the string
is never parsed just send a real linefeed in your xml

"Farm" <eritreoc@hotmail.com> wrote in message
news:B96A8E7F-870B-4EF1-BBA5-B042EB028A49@microsoft.com...
> Hi, I have a problem with special character \n using in alert() function
that shows \n character like string and not as carriage return.
>
> Release note:
> -------------------------------------------------------------------
> I use javascript in Internet Explorer 6.0
> SO Windows XP Italian version sp2
> I extract some literal text that contain \n from XML node using
Microsoft.XMLHTTP object (for example the literal string 'Save the\n
record?')
> I retrieve XML from my web services
>
> Same Code:
> -------------------------------------------------------------------
> <script language=javascript>
> //<!--
> function GetNodeText() {
>
> var TextNode
> TextNode= xmlDoc.selectSingleNode('//ReadRecordResult') ;
> if (TextNode != null) {
> return TextNode.text ;
> } else {
> return empty;
> }
> }
>
> //...and I pass result of this function to alert():
>
> alert(GetNodeText()) ;
>
> // --></script>
>
> Can you give us some advice ?
>
> Thank you very much.



Relevant Pages

  • Re: Strongly-Typed DataSet Woes
    ... I'm using a strongly-typed DataSet and its accompanying TableAdapter's Fill ... XML string and then I am using the dataset's ReadXML method and passing it ... contain the \" escape sequence around the root element's xmlns value. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Strongly-Typed DataSet Woes
    ... the XML string in, rather than a StringReader. ... As I prepare to put the web serivices's xml into a new, ... The error is encountered when the DataSet attempts to load the ... time and it does contain the \" escape sequence around the root element's ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: # in XML string
    ... an escape sequence and if there is a way to get it into my string. ... XML uses the ampersand '&' to start character or entity references. ...
    (comp.text.xml)
  • Re: XPath and Serialization
    ... is it possible to retrieve the XML for a node as a ... > string so that i can use XML Serialization to instantiate an object ... If you don't need XPath, you can use plain XmlTextReader for that. ...
    (microsoft.public.dotnet.xml)
  • Re: SP1 Problem SOAPException doesnt return quote and Umlaute correcty
    ... Our app returns XML in the fault string. ... returned in the fault string of a soap exception. ...
    (microsoft.public.dotnet.framework.webservices)