[thelist] XSL carriage return replacement

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Thu Aug 15 08:34:01 CDT 2002


>I am having an XSL problem. I am losing the carriage returns from the
>xml file. I know that there must be a way that I can replace the 

>with a <br /> or &lt; br /&gt; for the whole file not just one node. In
>other words I have multiple nodes in the xml that have carriage returns.
>If someone know of a way to do this with XSL that would be great.

Read the XML into a DOM object, select the nodes you want to preserve
carriage returns, then loop through the selected nodes and replace carriage
returns on each.

You could do (in VBScript with MSXML ):

	Set oXml = Server.CreateObject( "Msxml2.DomDocument.3.0" )
	Set oNodes = oXml.SelectNodes( "/path/to/nodes/to/check" )
	For each oNode in oNodes
		oNode.Value = Replace( oNode.Value, vbCrLf, "<br/>" )
	Next
	... pass through XSL ...

Syntax may be slightly off in a couple places but it probably works. I've
done stuff like this before.

HTH,
-dave



More information about the thelist mailing list