Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Load XML elements on HTML page

from a different server

     

visa666

12:09 am on Sep 15, 2009 (gmt 0)

5+ Year Member



Hi Everybody

I am trying to load selected elements of a xml dtd formatted page onto a html page.
The xml and html pages are on different servers.
Here is part of the xml page:
Quote:
-<shrs>
-<rq url="http://api.example.com/a/j-api/xml-v2/7">
<t>Doctor </t>
<dt>2009-09-14T22:24:19Z</dt>
<si>0</si>
<rpd>10</rpd>
<tr>200691</tr>
<tv>1000</tv>
<em url=""/>
-<h>
<kw pos="1"/>
</h>
</rq>
-<rs>
-<r>
<jt>Title</jt>
<cn url="">URL</cn>
<src url="http://api.example.com/a/j-api/xml-v2/7Dk0JmNfaWQ9NDgzNSZwX2lkPTEzNTcwJnBvcz0xJnpvbmU9NiZjcGM9MC4xNiZpcD0maGFzaD03NWNhMjlhMjQ0MTQzMzYwNzVk YTFiODI1ZjAwZDE5YiZjb3VudD0yJnN</src>
<ty>sponsored</ty>
<loc cty="" st="MS" postal="" county="" region="" country="US">STATES</loc>
<ls>2009-08-31T12:54:43Z</ls>
<dp>2009-08-31T12:54:43Z</dp>
-<e>
----------------------
</e>
</r>
.
.
.
.
.
.

Any ideas?

Thanks

[edited by: httpwebwitch at 1:01 pm (utc) on Sep. 17, 2009]
[edit reason] examplified [/edit]

httpwebwitch

1:09 pm on Sep 17, 2009 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I always use a server-side language to do this kind of thing. In PHP there is a simple XML parser [ca3.php.net] that you would find useful; similar facilities exist in C#.NET, Java, Perl, Python, Ruby, VBScript, etc.

First, you request the XML from the 3rd party server. Then you parse it and turn it into an XML object. Then use XPATH to grab the nodes you want, or perhaps iterate through nodes looking for pattern matches. Once found, the result can be output to your HTML page.

You can find practical examples here [ca3.php.net]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month