Java Reference
In-Depth Information
<CITY>New York</CITY>
<STATE>NY </STATE>
<ZIP>10007</ZIP>
<PHONE>201-555-1213</PHONE>
</CUSTOMER>
<CUSTOMER CUSTOMER_NUMBER="103">
<FIRST_NAME>Francis</FIRST_NAME>
<MI>X</MI>
<LAST_NAME>Corleone</LAST_NAME>
<STREET>17 Main</STREET>
<CITY>New York</CITY>
<STATE>NY </STATE>
<ZIP>10005</ZIP>
<PHONE>201-555-1215</PHONE>
</CUSTOMER>
</CUSTOMERS>
Just as you can generate XML from a database, you can also populate a database using an XML data
feed. The Internet offers many sources of XML data which can be used in this way. The next section
shows the use of an Internet data source to populate a database.
Populating a Database Using XML Data Sources
XML's rise to prominence as a B2B solution has led to the introduction of a number of XML-based
services accessible over the Internet. An excellent example of such a service is the XML-based news
service on the demonstration portal maintained by Moreover.com .
Listing 17-10 illustrates the format of the top stories headline link page available at:
http://www.moreover.com/cgi-local/page?o=xml&query=top+stories.
The XML document contains the root tag <moreovernews> , which, in turn, contains a number of
<article> elements. Each of these elements contains 11 child elements. Together, the <article>
elements and their nested child elements can be envisaged as the rows of a database table with 11
columns corresponding to the 11 child elements.
Listing 17-10: XML top stories headline format from Moreover.com
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE moreovernews SYSTEM
"http://p.moreover.com/xml_dtds/moreovernews.dtd">
<!-- by using this feed you have read and agree to our terms and
conditions
at http://w.moreover.com/site/about/termsandconditions.html
If the presence of this comment has caused an error in your parser
you may
use the older uncommented version by using &amp;o=xml_1 or +xml_1 in
the URL.
Using the xml_1 version still means that you have read and agree to
Search WWH ::




Custom Search