remove line breaks from xml

  • Help how can i remove line breaks from my xml data when i export it to excel it breas

  • raymond.konker.williams (9/4/2014)


    Help how can i remove line breaks from my xml data when i export it to excel it breas

    Not so much information about how you are doing things, it is easier to answer if you have some code examples.

    But it is possible to cast your XML into a string and just remove the characters you don't want:

    declare @xml xml

    set @xml = '<root>

    <sometag1>

    <somechild value="a value" />

    This tag has some text,

    and the text has line breaks.

    </sometag1>

    </root>'

    select cast(@xml as varchar(max)) AS WithLineBreaks, replace(replace(cast(@xml as varchar(max)), char(13), ''), char(10), '') AS WithoutLineBreaks

    But again, it depends on where the linebreaks are. The example above will remove all linebreaks, both between the tags and inside the tags.

    But depending on the problem, the solution might be to change some setting in Excel or in SSMS (like setting the query-window in SSMS to "quote" strings and then instruct Excel that strings are quoted...

    So if the sugestions here does not solve your problem, try to describe it better - what are you trying to achieve and how have you tried to solve it so far. 🙂

    Good luck!

    /M

  • raymond.konker.williams (9/4/2014)


    Help how can i remove line breaks from my xml data when i export it to excel it breas

    Hi and welcome to the forum.

    Could you provide some sample data, and expected results, makes it easier to provide an accurate answer, for more information, have a quick look at this article How to post data/code on a forum to get the best help[/url]

    😎

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply