Toad World® Forums

TOAD XML Formatting Issue


#1

Hi,

What is the way to format a xml file? whenever I open a xml file it shows in one line.


#2

Let’s have a look at this XML document called “shiporder.xml”:

<?xml version="1.0" encoding="UTF-8"?>

<shiporder orderid=“889923”

xmlns:xsi="www.w3.org/…/XMLSchema-instance"

xsi:noNamespaceSchemaLocation=“shiporder.xsd”>

John Smith

Ola Nordmann

Langgt 23

4000 Stavanger

Norway

Empire Burlesque

Special Edition

1

10.90

Hide your heart

1

9.90

The XML document above consists of a root element, “shiporder”, that contains a required attribute called “orderid”. The “shiporder” element contains three different child elements: “orderperson”, “shipto” and “item”. The “item” element appears twice, and it contains a “title”, an optional “note” element, a “quantity”, and a “price” element.

The line above: xmlns:xsi="www.w3.org/…/XMLSchema-instance" tells the XML parser that this document should be validated against a schema. The line: xsi:noNamespaceSchemaLocation=“shiporder.xsd” specifies WHERE the schema resides (here it is in the same folder as “shiporder.xml”).

Thank you wish you all the best.


#3

Hi,

Thank you for the answer. But my question is , if i copy the above code , past it in text and save it as .xml then when I open the same file in toad:

Toad will show this file in two lines:

first line: <?xml version="1.0" encoding="UTF-8"?>

remaining all will be in second line.

How can I format this file to show the xml as it is shown above in your example.


#4

You should place (check) option in Toad Options, Schema Browser|Data Tab|“Allways Cast XMLType columns to CLOB”

I see the whole content in data tab with that


#5

Hi,

I am on version 11.6 and am not able to find this check option under Schema Browser.


#6

Damir, that option refers to Toad putting a GetClobVal() function around the XMLTYPE column in the SQL Statement. We do this because the OCI when in Unicode mode has a lot of problems with XMLTYPE. It doesn’t have anything to do with some or all of the data showing up or not. OP just has all of his XML on two lines (the header line and the rest of it) and wants to format it.

Unfortunately, because of this OCI limitation, support for XMLTYPE in Toad is limited, and there is no way to format it in Toad. Sorry.