Extracting data from XML document

K

Ken

What I mean by the below question is rather : What software is
required to extract certain data from an XML document that is served
from another website?
 
M

Martin Honnen

Ken said:
What I mean by the below question is rather : What software is
required to extract certain data from an XML document that is served
from another website?

XML parsers know how to load files via HTTP so all you need is an XML
parser. Check http://xml.apache.org/ for XML parsers.
 
P

Patrick TJ McPhee

% What I mean by the below question is rather : What software is
% required to extract certain data from an XML document that is served
% from another website?

What do you want to do? There are programs which can extract data
and stick it a relational database. There are programs which can
extract data and write it to a flat file. There are libraries which
can feed data directly to an application you've written.
 
K

Ken

I want to extract the data and put them into an access database. But
do tell me more about the other programs like libraries which can feed
data directl y to an application I have written.

Tks
 
K

Ken

Thanks Devon. I use your method and can't seem to return the required
elements. Can you tell me what's wrong with the code below? The code
is adapted from http://www.w3schools.com/xsl/xsl_value_of.asp


--------------- code start here -------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates
select="document('http://www.w3schools.com/xsl/cdcatalog.xml')"/>
</xsl:template>

<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of select="catalog/cd/title"/></td>
<td><xsl:value-of select="catalog/cd/artist"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

-------------------- code end here -------------------
 
A

Andy Dingley

Thanks Devon. I use your method and can't seem to return the required
elements. Can you tell me what's wrong with the code below? The code
is adapted from http://www.w3schools.com/xsl/xsl_value_of.asp

Try this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="doc"
select="document('http://www.w3schools.com/xsl/cdcatalog.xml')"/>

<xsl:template match="/">

<html><body>
<h2>My CD Collection</h2>

<table border="1">
<tr bgcolor="#9acd32"><th>Title</th><th>Artist</th></tr>

<xsl:for-each select="$doc/catalog/cd" >
<tr>
<td><xsl:value-of select="./title"/></td>
<td><xsl:value-of select="./artist"/></td>
</tr>
</xsl:for-each>

</table>
</body></html>
</xsl:template>

</xsl:stylesheet>



If you want to see it quickly in client-side IE, save it as
xsl_document.xsl and try browsing the following xml document

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="xsl_document.xsl" ?>

<foo />
 
P

Patrick TJ McPhee

% I want to extract the data and put them into an access database. But
% do tell me more about the other programs like libraries which can feed
% data directl y to an application I have written.

I was thinking specifically of XML parsers, and in particular parsers
which have XPath implementations. There are many of them floating around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top