1 Reply Latest reply: Jan 11, 2012 3:27 AM by AlexAnd RSS

    XML format

    897410
      Hello, I want to extract a table in xml format, with this specific format, I was not able, coulld you help me?

      For example, If we have:

      Id Card Name
      1 Renault Peter
      2 Citroen Charly
      3 Nissan Pierre
      4 Renault Lucas

      I want some thing like:

      <export>
      <card TYPE="Renault">
      <Customer name="Peter"></Customer>
      <Customer name="Lucas"></Customer>
      </card>
      <card TYPE="Citroen">
      <Customer name="Charly"></Customer>
      </card>
      <card TYPE="Nissan">
      <Customer name="Pierre"></CUstomer>
      </card>
      </export>

      Thank you
        • 1. Re: XML format
          AlexAnd
          something
          with t as
           (select 1 id, 'Renault' card, 'Peter' name
              from dual
            union all
            select 2, 'Citroen', 'Charly'
              from dual
            union all
            select 3, 'nissan', 'pierre'
              from dual
            union all
            select 4, 'Renault', 'Lucas' from dual)
          select xmlelement("export",
                            xmlagg(xmlelement("card",
                                              xmlattributes(card as "type"),
                                              xmlagg(xmlelement("Customer",
                                                                xmlattributes(name as
                                                                              "name"))))                         
                                   ))
            from t
           group by card
          Edited by: AlexAnd on Jan 11, 2012 1:26 AM