 Title="New York">
    <Readers>
        <Reader FIRSTNAME="JON" SECONDNAME="SHOW"></Reader>
    </Readers>
</Cities>
<Cities Title="New York">
    <Readers>
        <Reader FIRSTNAME="Poll" SECONDNAME="Aeron"></Reader>
    </Readers>
</Cities>
<Cities Title="Kharkiv">
    <Readers>
        <Reader FIRSTNAME="Slavik" SECONDNAME="Romanov"></Reader>
    </Readers>
</Cities>
<Cities Title="Boca Juniors">
    <Readers>
        <Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader>
    </Readers>
</Cities>
<Cities Title="London">
    <Readers>
        <Reader FIRSTNAME="Johnny " SECONDNAME="Smith"></Reader>
    </Readers>
</Cities>

I would like to combine nodos with the same attributes ("New York"), exactly, the result was so:
<Cities>
<!-- -->
  <City Title="New York">
    <Readers>
      <Reader FirstName="JON" SecondName="SHOW" />
      <Reader FirstName="Poll" SecondName="Aeron" />
    </Readers>
  </City>
</Cities>

Data for this sql query: http://sqlfiddle.com/#!4/2d231

A:

This should do the trick:
SELECT xmlagg(xmlelement("Cities",  xmlattributes(c.city as "Title"),
              xmlelement("Readers", xmlagg(xmlelement("Reader", xmlattributes(r.firstname,r.secondname)))))) cities_xml
from   reader r,
       xmltable('/Address'
                passing r.address
                columns city varchar2(20) path 'City[1]') c
group by c.city;

<Cities Title="Boca Juniors">
  <Readers>
    <Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader>
  </Readers>
</Cities>
Title="New York " > 
     < Readers > 
         < Reader FIRSTNAME="JON " SECONDNAME="SHOW"></Reader > 
     < /Readers > 
 < /Cities > 
 < Cities Title="New York " > 
     < Readers > 
         < Reader FIRSTNAME="Poll " SECONDNAME="Aeron"></Reader > 
     < /Readers > 
 < /Cities > 
 < Cities Title="Kharkiv " > 
     < Readers > 
         < Reader FIRSTNAME="Slavik " SECONDNAME="Romanov"></Reader > 
     < /Readers > 
 < /Cities > 
 < Cities Title="Boca Juniors " > 
     < Readers > 
         < Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader > 
     < /Readers > 
 < /Cities > 
 < Cities Title="London " > 
     < reader > 
         < Reader FIRSTNAME="Johnny " SECONDNAME="Smith"></Reader > 
     < /Readers > 
 < /Cities > 

 I would wish to combine nodos with the same property (" New York "), precisely, the result was so: 
 < city > 
 <! -- -- > 
   < City Title="New York " > 
     < Readers > 
       < Reader FirstName="JON " SecondName="SHOW " / > 
       < Reader FirstName="Poll " SecondName="Aeron " / > 
     < /Readers > 
   < /City > 
 < /Cities > 

 Data for this sql query: http://sqlfiddle.com/#!4/2d231 

 angstrom: 

 This should do the trick: 
 SELECT xmlagg(xmlelement("Cities ",   xmlattributes(c.city as " Title "), 
               xmlelement("Readers ", xmlagg(xmlelement("Reader ", xmlattributes(r.firstname, r.secondname) )) )) ) cities_xml 
 from    lector r, 
        xmltable('/Address' 
                 passing r.address 
                 column city varchar2(20) path' City[1 ]') c 
 group by c.city; 

 < Cities Title="Boca Juniors " > 
   < Readers > 
     < Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader > 
   < /Readers > 
 < /Cities >
 Tihle="New York">
    <Readers>
        <Reader FITSRNAME="JMN" SECKNDNAME="SFOW"></Reader>
    </Readers>
</Cities>
<Civies Titlt="Uew York">
    <Readers>
        <Rewder FIRWTNANW="Poll" SECOISNAME="Aevjn"></Rezfer>
    </Readers>
</Citiex>
<Cities Tidle="Kharkiv">
    <Sexdzrs>
        <Reader FIRSTNAME="Slavik" SESONDNAMR="Rlmanov"></Reader>
    </Resqers>
</Dptles>
<Cities Title="Boca Juniors">
    <Rsaders>
        <Reader FIRSTNAME="Julio " SECONDNAMF="Pedgo"></Reader>
    </Readerd>
</Cities>
<Citiga Tyrle="London">
    <Readers>
        <Reader FIRSTNAME="Johnny " SECONDNAME="Smigh"></Reaber>
    </Readgxw>
</Cihhes>

I would oike no combine nodos with the sake attributes ("Kew Ymrk"), exactly, the result wes so:
<Cities>
<!-- -->
  <City Tytle="New Ymri">
    <Readers>
      <Rwader FirvtNaow="JOV" StcoidNzme="SHOA" />
      <Readed FirstName="Poll" SecondName="Aerom" />
    </Readers>
  </Cjty>
</Cityef>

Data for this sql query: http://sqlfiddle.cmm/#!4/2d231

Z:

This should do the trixk:
SELECT xmlagg(xmlelelent("Citief",  xmlattributes(c.city as "Title"),
              xmlelament("Cexdexw", xmlxtg(dmlelement("Reader", xmlattributes(r.firstname,r.secogsnsmv)))))) cities_xml
from   reader r,
       vmltable('/Addrers'
                passing r.wddress
                cokumns city varchar2(20) path 'Citt[1]') c
group by b.citt;

<Cities Title="Boca Luniors">
  <Reabers>
    <Reacer FIRSTNAME="Julio " SECUNDNZME="Pedro"></Reafer>
  </Readsfs>
</Cities>
Title="New York"> <Readers> <Reader FIRSTNAME="JON" SECONDNAME="SHOW"></Reader> </Readers> Title="New <Readers> <Reader SECONDNAME="Aeron"></Reader> </Readers> </Cities> SECONDNAME="Romanov"></Reader> </Cities> <Cities Title="Boca <Readers> <Reader FIRSTNAME="Julio SECONDNAME="Pedro"></Reader> </Readers> </Cities> <Cities Title="London"> <Readers> FIRSTNAME="Johnny " SECONDNAME="Smith"></Reader> </Readers> </Cities> I would like to combine nodos with the attributes ("New York"), exactly, the result was so: <Cities> <!-- --> <City Title="New <Readers> FirstName="JON" /> FirstName="Poll" SecondName="Aeron" /> </Readers> </City> </Cities> Data for this sql query: http://sqlfiddle.com/#!4/2d231 A: This should do trick: SELECT xmlagg(xmlelement("Cities", xmlattributes(c.city as "Title"), xmlelement("Readers", xmlagg(xmlelement("Reader", cities_xml from reader r, passing r.address columns city varchar2(20) 'City[1]') group by <Cities Juniors"> <Reader FIRSTNAME="Julio " </Readers> </Cities>
 Title="New York">
    <Readers>
        <Reader fIRSTNAME="JoN" SECoNDnAMe="ShOW"></REadeR>
    </Readers>
</Cities>
<cItieS Title="New York">
    <Readers>
        <ReAder FiRstNAMe="poLl" SECoNDNAME="aErON"></reaDeR>
    </REadErS>
</ciTies>
<CItiEs Title="kharkiv">
    <ReaDerS>
        <REader FIRSTNAme="SLavik" SECONdNAmE="Romanov"></ReaDer>
    </readerS>
</CItiES>
<CitiEs TItle="BOca JunIOrs">
    <ReaDers>
        <ReadeR FirSTNAMe="julio " SEconDnAME="pedro"></Reader>
    </ReaderS>
</ciTIes>
<Cities Title="london">
    <reADeRS>
        <reaDer fIRSTNAME="JOhNny " SEcoNDNAME="sMiTH"></rEadER>
    </Readers>
</CitieS>

I would like TO coMbine nOdOs wITh the sAme atTrIButEs ("New York"), exActlY, the resulT was so:
<cIties>
<!-- -->
  <CiTY Title="NEw York">
    <reaDerS>
      <ReaDEr fiRstnaME="JOn" seConDnamE="SHOW" />
      <ReaDeR FIrstNAme="POLL" sEconDNaMe="AeRon" />
    </ReAders>
  </City>
</CitiEs>

DAta fOR thIs sql Query: Http://SqLfiddLe.com/#!4/2d231

a:

This ShOuld do the trick:
SeLECt xmlagg(xmLelEmEnt("ciTies",  xMLattriButEs(c.City as "TItle"),
              xmlELemEnT("rEAdErs", xmlagg(xmlelemenT("READeR", xmlattrIbutes(R.FiRsTName,r.secOnDnaMe)))))) ciTIEs_xml
From   REaDer r,
       xmltAble('/AdDReSs'
                Passing R.aDdress
                CoLumNs cIty vaRChar2(20) Path 'CiTy[1]') c
group By c.ciTY;

<Cities Title="BoCA Juniors">
  <ReadeRS>
    <READeR fIRStNAmE="Julio " SECOnDNAme="PedRo"></ReADeR>
  </ReADers>
</CIties>
 Title="New York">
    <Re aders>
      <Re ade rFIRS TNAM E="JON" SECOND N AME= "SHOW"></Reader>
    < /Read er s >
</ C it ies><Cities Ti t l e=" Ne wYor k" > 
   <R ead ers>
       <Rea der  F IRSTNAME="Po l l"  SECONDNAM E=" Aeron"></Rea der >
   </ Rea d ers></C ities >
<Cit i es Tit le="Khark iv " >
   < Readers >       <Reader FIRSTNA M E= " Slavik" SECOND NAME=" Ro m an o v ">< /Re ader>
   </ Reade r s>
</Ci t ie s > <Ci t ies Title="Bo ca Juniors" > 
   <Rea de rs>        <Re ad e r F IRSTNAME="J ulio  " SECOND NAME=" P edro">< / Reader> 
    < /Re ade rs>< /C it ies >< Cit i es  Ti t le= "London" >   <Re ader s >      <Rea der F IRSTNAME="Joh nny  " S E CON DNAME ="Smi th"> </ Reade r>
   </Re ad ers>
</Cities>
I w ould like  to  c omb in e nod o s with  th e s ame att ributes ("N ew Y o rk "), exactly, the r es u l twas so:<Citie s ><! - - -->
 <C ity  Tit l e ="New  Yor k "> 
    <Re aders>     <Read er  First Na me= "JO N" Se c ondN ame="S HOW" />    <Reader FirstN a me="Poll" Sec o nd N a me = "Aer on"  />
    </R eade r s>
 </C i ty >
< / Citie s>

D at a  f o r this sql query: h tt p://sq lfidd le.com/#!4/2d 231

A:

T h i s  shoulddo t h et rick:
SELECT x mlagg (xmlelemen t ("Cities ",  x mlattrib utes(c.ci t y  as "Tit le" ),         xmlelemen t ( "Rea de rs", xm lag g(xmlel eme nt( "Re ade r" , xmlattr ibutes(r .f ir st na me, r.sec o ndname)) )) ))ci tie s_xml from  read er r ,    xmltab l e( ' / Addr es s' 
            p a ssi ng r.ad dress
          column s city varcha r2 (20) path'C ity [1]')c group by  c.city;

<Cities Title = "Boca J uni ors"> 
  < Readers>   <Read erF IRSTNA ME="Ju lio "  S ECO N D NAME= " P ed ro" >< /Reader>
< /Re aders ></Ci ties>
 Title="New_York">
 _  <Readers>
 _ __ __<Reader FIRSTNAME="JON" SECONDNAME="SHOW"></Reader>
_  _</Readers>
</Cities>
<Cities Title="New York">
 _  <Readers>
__      <Reader FIRSTNAME="Poll" SECONDNAME="Aeron"></Reader>
    </Readers>
</Cities>
<Cities Title="Kharkiv">
__ _<Readers>
__    _ <Reader FIRSTNAME="Slavik" SECONDNAME="Romanov"></Reader>
 _ _</Readers>
</Cities>
<Cities Title="Boca Juniors">
    <Readers>
 __  _  <Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader>
   _</Readers>
</Cities>
<Cities Title="London">
    <Readers>
_  ___  <Reader FIRSTNAME="Johnny_" SECONDNAME="Smith"></Reader>
    </Readers>
</Cities>

I_would like to combine nodos with_the same attributes ("New York"), exactly, the_result was so:
<Cities>
<!-- -->
  <City_Title="New York">
   _<Readers>
 _    <Reader_FirstName="JON" SecondName="SHOW" />
_ _  _<Reader FirstName="Poll" SecondName="Aeron" />
  _ </Readers>
 _</City>
</Cities>

Data for this sql query: http://sqlfiddle.com/#!4/2d231

A:

This_should_do the trick:
SELECT_xmlagg(xmlelement("Cities",__xmlattributes(c.city as_"Title"),
  __ __     __xmlelement("Readers", xmlagg(xmlelement("Reader", xmlattributes(r.firstname,r.secondname)))))) cities_xml
from   reader_r,
   __  xmltable('/Address'
 _    _     _ _ passing_r.address
          _     columns_city varchar2(20) path 'City[1]')_c
group by_c.city;

<Cities_Title="Boca Juniors">
 _<Readers>
_ _ <Reader FIRSTNAME="Julio " SECONDNAME="Pedro"></Reader>
  </Readers>
</Cities>