Search code examples
xmldomtemp-tablesopenedgeprogress-4gl

how to read xml file with multiple elements and write to temp-table using progress 4gl dom?


Please help me read this xml file and write to temp-table using progress 4gl

MY xml file is shown below.

 <?xml version="1.0" encoding="UTF-8"?>

        <bookstore>
          <bookone>
            <title>Everyday Italian</title>
            <author>Giada De Laurentiis</author>
            <year>2005</year>
            <price>30.00</price>
          </bookone>

          <cars>
            <model>
            <plate>12345</plate>
            <purchase>04/03/2011</purchase>
            <insurence>yes</insurence>
            </model>

          <model>
          <plate>56789</plate>
          <purchase>04/03/2011</purchase>
          <insurence>no</insurence>
          </model>

        </cars>

        <booktwo>
            <title>XQuery Kick Start</title>
            <author>James McGovern</author>
            <author>Per Bothner</author>
            <author>Kurt Cagle</author>
            <author>James Linn</author>
            <author>Vaidyanathan Nagarajan</author>
            <year>2003</year>
            <date>02/05/2009</date>
          </booktwo>


        </bookstore>

I have tried a code with repeat statement but doesn't work.


Solution

  • Progress 4gl comes with inbuilt parsers for XML. There is Sax and Dom. The Sax parser will be more useful to you in reality, and there is a pretty good starting point on how to use it in the documentation, here: https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvxml/example-code-3a-reading-customer-data-and-writing.html