how to avoid indent - leading spaces in xml while using extract on xmltype
663181Oct 3 2008 — edited Oct 10 2008I am using Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
------------------------------------------------------------------------
Hi,
I have an issue using .extract('/').
my query
select xmlelement("list",
xmlelement("Card",
xmlelement("Name", name),
xmlelement("card_id", card_id)
)
).extract('/') as xml from card where card_id < 3;
gives me an output
<list>
tab<Card>
tabtab<Name>Card_1</Name>
tabtab<card_id>1</card_id>
tab</Card>
tab<Card>
tabtab<Name>Card_2</Name>
tabtab<card_id>2</card_id>
tab</Card>
</list>
my expected output:
<list>
<Card>
<Name>Card_1</Name>
<card_id>1</card_id>
</Card>
<Card>
<Name>Card_2</Name>
<card_id>2</card_id>
</Card>
</list>
Please note the difference is - there are indent spaces(tabs, empty char spaces) at the start of each line for subtags in the output xml.
but I need all my tags to start from the first character on each line. My xml file is very big in size, so I am looking at reducing the filesize by eliminating these spaces.
I have ensured that the program that consumes my xml works fine with both of above xml.
I would appreciate your replies.
Thanks