XML to create from an oracle query -


i wrote below query generate xml file

 select xmlelement("providers",                     xmlelement("provider" ,xmlattributes(                                         "unique id" "uniqueid"),                     xmlelement("providertype", "provider type"),                    xmlelement("specialities",                    xmlelement("speciality", "specialty")),                    xmlelement("relationships",                    xmlelement("relationship", "relationship")),                    xmlelement("serviceaddress",                    xmlelement("addressline1","p address line 1"),                    xmlelement("addressline2","p address line 2"),                     xmlelement("addressline3","p address line 3"),                     xmlelement("addressline4","p address line 4"),                    xmlelement("city","service city description"),                    xmlelement("region","pstate_province_region"),                    xmlelement("postalcode","ppostal code"),                    xmlelement("isocountrycode","servicecountry iso code")),                    xmlelement("contacts",                         xmlelement("contactinfo",                             xmlelement("contacttype","contact type"),                             xmlelement("name","contact name"),                             xmlelement("title","contact title"),                             xmlelement("function","contact function"),                             xmlelement("phoneno","contact phone number"),                             xmlelement("cellno","contact cell phone number"),                             xmlelement("email","contact e-mail") ))))                     "result"  providers_xml 

but create seperate xml file each row in table provider below

file 1

<?xml version="1.0"?> -<providers>  -<provider uniqueid="aa">   <providertype>1</providertype>   -<specialities>    <speciality>210</speciality>   </specialities>   -<relationships>    <relationship/></relationships>   -<serviceaddress>    <addressline1>abc</addressline1>    <addressline2/><addressline3/>    <addressline4/>    <city>city123</city>    <region/>    <postalcode/>    <isocountrycode>us</isocountrycode>    </serviceaddress>   -<contacts>    -<contactinfo>     <contacttype>1</contacttype>     <name>general contact</name>     <title/>     <function/>     <phoneno/>     <cellno/>     <email/>     </contactinfo>    </contacts>   </provider> </providers> 

file 2

<?xml version="1.0"?> -<providers>  -<provider uniqueid="abc">   <providertype>1</providertype>   -<specialities>    <speciality>100</speciality>   </specialities>   -<relationships>    <relationship/></relationships>   -<serviceaddress>    <addressline1>zxy</addressline1>    <addressline2/><addressline3/>    <addressline4/>    <city>city300</city>    <region/>    <postalcode/>    <isocountrycode>us</isocountrycode>    </serviceaddress>   -<contacts>    -<contactinfo>     <contacttype>2</contacttype>     <name>general contact</name>     <title/>     <function/>     <phoneno/>     <cellno/>     <email/>     </contactinfo>    </contacts>   </provider> </providers> 

but need these files 1 below

-<providers>      -<provider uniqueid="aa">       <providertype>1</providertype>       -<specialities>        <speciality>210</speciality>       </specialities>       -<relationships>        <relationship/></relationships>       -<serviceaddress>        <addressline1>abc</addressline1>        <addressline2/><addressline3/>        <addressline4/>        <city>city123</city>        <region/>        <postalcode/>        <isocountrycode>us</isocountrycode>        </serviceaddress>       -<contacts>        -<contactinfo>         <contacttype>1</contacttype>         <name>general contact</name>         <title/>         <function/>         <phoneno/>         <cellno/>         <email/>         </contactinfo>        </contacts>       </provider>      -<provider uniqueid="abc">       <providertype>1</providertype>       -<specialities>        <speciality>100</speciality>       </specialities>       -<relationships>        <relationship/></relationships>       -<serviceaddress>        <addressline1>zxy</addressline1>        <addressline2/><addressline3/>        <addressline4/>        <city>city300</city>        <region/>        <postalcode/>        <isocountrycode>us</isocountrycode>        </serviceaddress>       -<contacts>        -<contactinfo>         <contacttype>2</contacttype>         <name>general contact</name>         <title/>         <function/>         <phoneno/>         <cellno/>         <email/>         </contactinfo>        </contacts>       </provider>     </providers> 

please desired o/p

add xmlagg clause.

 select xmlelement("providers",              **xmlagg(**                xmlelement("provider" ,xmlattributes(                                     "unique id" "uniqueid 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -