Coverting XML to a string

Questions about XML that are not covered by the other forums should go here.
tom77
Posts: 3
Joined: Thu Jul 07, 2016 12:20 pm

Coverting XML to a string

Post by tom77 »

Hi,

We need to insert xml data into our stub test database as a string.

I'm using oxygen v15. Does this function exist? I've had a look but can't see any obvious way to do this.

Many thanks,

Tom
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Coverting XML to a string

Post by Radu »

Hi Tom,

I'm not sure what you mean by "string". The entire XML content is a string of characters. Maybe you can save it directly as it is.
Do you want to escape characters like "<" and ">"? If you open the XML in the text editing mode, select all, right click and use the action Source->Escape Selection you have various options to escape the XML content there.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tom77
Posts: 3
Joined: Thu Jul 07, 2016 12:20 pm

Re: Coverting XML to a string

Post by tom77 »

Thanks Radu,

To clarify, to want to remove the indent/formatting so that the xml is a single row of text.

Previously, I have used firefox, i.e. copy the formatted xml into the firefox url, then copy from there into notepad or directly into the sql insert statement.

However, for some reason this method has become inconsistent - i.e. whitespace can get removed which makes the xml invalid.

I am not looking for any characters to get removed.

Thanks again,

Tom
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Coverting XML to a string

Post by Radu »

Hi Tom,

If you select the entire content, you can right click and choose Source->Join and Normalize lines.
But I still do not understand why the database would not allow line breaks in the cell data content.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tom77
Posts: 3
Joined: Thu Jul 07, 2016 12:20 pm

Re: Coverting XML to a string

Post by tom77 »

Radu,

Thanks a lot - this has resolved my issue!

The development resource who is helping me with this has asked for the xml in this format purely to keep the rows tidy and easy to view.

Thanks,

Tom
Post Reply