Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Wednesday, September 2, 2009

parsing the google trends atom feed rss


$feed = simplexml_load_file('http://www.google.com/trends/hottrends/atom/hourly');
$children = $feed->children('http://www.w3.org/2005/Atom');
$parts = $children->entry;
foreach ($parts as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
$dom = new domDocument();
@$dom->loadHTML($details->content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$url = $anchor->getAttribute('href');
$urltext = $anchor->nodeValue;
echo 'Link: ' . $urltext . ' ';
}
}

Tuesday, March 10, 2009

Loading an XML file with Javascript.

Should fill the data from the XML file into the span tag on the HTML document.

<script type="text/javascript">
function parseXML()
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.async=false;
xmlDocVal = "/xmlfile.xml";
xmlDoc.load(xmlDocVal);
document.getElementById("divtarget").innerHTML=
xmlDoc.getElementsByTagName("xmlnodesource")[0]
.childNodes[0].nodeValue;

XML File
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xmlnodesource>Data</xmlnodesource>

HTML
<span id="divtarget"></span>

Basic ASP XML Output

ASP XML Output

<%
response.contentType="text/xml"
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<note>mooage</note>")
%>