Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:02:45+00:00 2026-06-17T19:02:45+00:00

The XML generated by using XMLAgg(XMLElement(‘student’, …)…) spits out everything onto one line. Given

  • 0

The XML generated by using

XMLAgg(XMLElement('student', ...)...)

spits out everything onto one line. Given that I have a very large table, it reaches line length limit when spooling.

I’d like to have each <student>…</student> node on a separate line. This page suggests using XMLText(x’0A’) to insert new lines, but SQLPlus doesn’t seem to recognize it.

I’ve already tried :

set long 2000000000
set linesize 32767
set wrap on
set trimspool on
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:02:47+00:00Added an answer on June 17, 2026 at 7:02 pm

    The usual trick in 10g was to add .extract('/*') on the outer xml operation you were doing eg

    xmlagg(....).extract('/*')
    

    but that doesn’t work in 11g. for a cross version compatible one using an xsl transform see Generate XML file with Customized XML tags out of oracle database table.

    10.2.0.4:

    SQL> create table foo (id) as select rownum from dual connect by level <= 2;
    
    Table created.
    
    SQL> select xmlagg(xmlelement("id", xmlelement("id2", id))).extract('/*') a from foo;
    
    A
    --------------------------------------------------------------------------------
    <id>
      <id2>1</id2>
    </id>
    <id>
      <id2>2</id2>
    </id>
    
    SQL> select xmlserialize(content xmlagg(xmlelement("id", xmlelement("id2", id))).extract('/*') indent) a from foo;
    select xmlserialize(content xmlagg(xmlelement("id", xmlelement("id2", id))).extract('/*') indent) a from foo
                                                                                                    *
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    
    
    SQL> select xmlagg(xmlelement("id", xmlelement("id2", id))).transform(xmltype('<xsl:stylesheet version="1.0"
      2   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      3   <xsl:output omit-xml-declaration="yes" indent="yes"/>
      4   <xsl:template match="node()|@*">
      5    <xsl:copy>
      6     <xsl:apply-templates select="node()|@*"/>
      7    </xsl:copy>
      8   </xsl:template>
      9  </xsl:stylesheet>')) a from foo;
    
    A
    --------------------------------------------------------------------------------
    <id>
      <id2>1</id2>
    </id>
    <id>
      <id2>2</id2>
    </id>
    

    and 11.2.0.2/3:

    SQL> select xmlagg(xmlelement("id", xmlelement("id2", id))).extract('/*') a from foo;
    
    A
    --------------------------------------------------------------------------------
    <id><id2>1</id2></id><id><id2>2</id2></id>
    
    SQL> select xmlserialize(content xmlagg(xmlelement("id", xmlelement("id2", id))).extract('/*') indent) a from foo;
    
    A
    --------------------------------------------------------------------------------
    <id>
      <id2>1</id2>
    </id>
    <id>
      <id2>2</id2>
    </id>
    
    SQL> select xmlagg(xmlelement("id", xmlelement("id2", id))).transform(xmltype('<xsl:stylesheet version="1.0"
      2   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      3   <xsl:output omit-xml-declaration="yes" indent="yes"/>
      4   <xsl:template match="node()|@*">
      5    <xsl:copy>
      6     <xsl:apply-templates select="node()|@*"/>
      7    </xsl:copy>
      8   </xsl:template>
      9  </xsl:stylesheet>')) a from foo;
    
    A
    --------------------------------------------------------------------------------
    
    <id>
     <id2>1</id2>
    </id>
    <id>
     <id2>2</id2>
    </id>
    

    in short, to do this version agnositc, you should use a XSL. if you’re only trying this for adhoc stuff, then extract is shorter to type on 10g and xmlserializeis shorter on 11g.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm accessing http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php using code generated by http://sudzc.com The SOAP message is being sent
I generated a Class with a XML Schema (.xsd) using the Visual Studio xsd
I'm working on a webflow (SWF2). The entities are generated using Roo. One of
I have an XML file generated using javax.sql.rowset.WebRowSet.writeXml which looks like: <metadata> This section
I want to load a xml file using Jquery . The xml is generated
I want to send XML generated from an object using Springs Jaxb2marshaller and jmsTemplate.convertAndSend(object)
Scenario: Sending XML, generated using php, via cURL to an external server for parsing.
Have an interesting one. I'm documenting a method using XML documentation comments in C#.
I have a xml file generated using moxy implementation of jaxb. However standalone value
I am having trouble getting a SOAP request out. I'm using generated client code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.