wondered if you could help me please? I have node in xml that is as followed
$LOG: 08880xbpnd $
fhdsafidsfsd
df
sd
fsd
f
sd
fsd
I was wondering is there anyway to make all the text go on to one line so that it then can be passsed through to a javascript function? so it would turn out like this
$LOG: 08880xbpnd $fhdsafidsfsddfsdfsdfsdfsd
Unfortunately, the
normalize-space()
function (used in the answer of andynormancx) does more than deleting newlines.It deletes all leading and trailing whitespace and it replaces any group of inner contigious whitespace with a single space character.
In many cases we want to deleteonly one type of a white-space character (as in the current case -- new lines (CR+LF is automatically normalized on reading by the XML parser to just LF).
The correct and safe way to do so is by using the standard XPath
translate()
function:returns a string obtained from the string-value of the current node in which any newline character is deleted.
Here is an example:
When the above transformation is applied on this source XML document:
The result is on one line only, as required, and all embedded spaces are left intact:
The normalize-space() XPath function should do what you want.