Conversion from database to XML


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Conversion from database to XML

  1. #1
    Rohit Lara Guest

    Conversion from database to XML


    I need to convert a table from a database ( like oracle or cloudscape) to
    an XML document. Is there a parser which I can use it?

  2. #2
    Peter Heintzen Guest

    Re: Conversion from database to XML


    "Rohit Lara" <lararohit@hotmail.com> wrote:
    >
    >I need to convert a table from a database ( like oracle or cloudscape) to
    >an XML document. Is there a parser which I can use it?


    Hi,

    the Oracle XML SQL Utilities for Java should solve your problem. With this
    utility you generate XML documents via SQL Statements. You can either manipulate
    table data via XML documents.
    The Oracle XML SQL utilities are for free. They can be downloaded from the
    Oracle Technology Network: http://technet.oracle.com/tech/xml/

    I hope this anwered your question.

    Regards

    Peter Heintzen

    Oracle German

  3. #3
    Rohit Wason Guest

    Re: Conversion from database to XML


    Rohit,
    for your information, "Parser" is a term generally used to break/ decipher
    the xml loaded on it, Not to create an XML document (generally).

    A simple way to create an XML doc would be to write a program to concatenate
    the data elements (fields etc.) into a string format (XML tagged strings)

    Cheers
    Rohit

    "Rohit Lara" <lararohit@hotmail.com> wrote:
    >
    >I need to convert a table from a database ( like oracle or cloudscape) to
    >an XML document. Is there a parser which I can use it?



  4. #4
    news.devx.com Guest

    Re: Conversion from database to XML

    If you're using ADO, it's simple.

    Open a Recordset, e.g. (SELECT * FROM <tablename>). Use the Recordset Save
    method with the adPersistXML flag to transform the data into XML. This saves
    the data using a schema from which you can reinstantiate the data into a
    recordset. Basically it contains meta information in one section. All the
    data is in a <rows> tag. One <row> for each row in the table. The Recordset
    saves field values as attributes.

    If you don't like that arrangement, simply concatenate the data yourself.
    For example (using VB)

    Dim s
    s = "<?xml version=""1.0""?>
    s = s & "<rows>
    Do While not R.EOF
    s = s & "<row>
    for each F in R.Fields
    if isNull(F.Value) then
    s = s & "<" & F.name & ">" & "NULL" & "<" & F.Name & ">"
    else
    s = s & "<" & F.name & ">" & cstr(F.Value) & "<" & F.Name & ">"
    end if
    next
    s = s & "</row>
    R.MoveNext
    Loop
    s = s & "</rows>

    Note that the example code is not very efficient for large tables, and it
    doesn't cover for errors that will occur if you have XML reserved characters
    (e.g. ampersand) in the data but it should give you the idea.


    "Rohit Lara" <lararohit@hotmail.com> wrote in message
    news:39976257$1@news.devx.com...
    >
    > I need to convert a table from a database ( like oracle or cloudscape) to
    > an XML document. Is there a parser which I can use it?




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center