Thread: Xml - Reaxml
View Single Post
  #6 (permalink)  
Old 15-05-2008, 02:26 AM
Bendy's Avatar
Bendy Bendy is offline
Junior Member
 
Join Date: May 2008
Posts: 8
Default I have got this far...

Hello Everyone,

I have tinkered around with it all and have managed to produce a table output Address, rent and bedrooms for rentals and Address and town for sales.

My question now is that I do not wish for this information to be displayed in this way. I want it to be displayed in a table but accross multiple lines. I have done up a rough drawing and attached it along with my code

your help is appreciated

Cheers

Ben

This is my html code for reading the xml file:
PHP Code:
<html>
<
body>

<
script type="text/javascript">
var 
xmlDoc=null;
if (
window.ActiveXObject)
{
// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (
document.implementation.createDocument)
{
// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Message from: St George Property Sales  We wish to advise you that your current browser can not interprate this site. Please use an alternate browser or update your current one ');
}
if (
xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("export.xml");

document.write("<h1>Rentals</h1>");
document.write("<table border='1'>");
document.write("<tr>");
document.write("<td>");
document.write("<b>Unique ID</b>");
document.write("</td>");
document.write("<td>");
document.write("<b>Rent</b>");
document.write("</td>");
document.write("<td>");
document.write("<b>Bedrooms</b>");
document.write("</td>");
document.write("</tr>");



var 
r=xmlDoc.getElementsByTagName("rental");
for (
i=0;i<r.length;i++)

document.write("<tr>");
document.write("<td>");
document.write(
r[i].getElementsByTagName("streetNumber")[0].childNodes[0].nodeValue);
document.write(" ");
document.write(
r[i].getElementsByTagName("street")[0].childNodes[0].nodeValue);
document.write(", ");
document.write(
r[i].getElementsByTagName("suburb")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write("$");
document.write(
r[i].getElementsByTagName("rent")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write(
r[i].getElementsByTagName("bedrooms")[0].childNodes[0].nodeValue);
document.write("</td>");

document.write("</tr>");
}
document.write("</table>");


document.write("<h1>Residential Sales</h1>");
document.write("<table border='1'>");
document.write("<tr>");
document.write("<td>");
document.write("<b>Unique ID</b>");
document.write("</td>");
document.write("<td>");
document.write("<b>Street Address</b>");
document.write("</td>");
document.write("</tr>");



var 
s=xmlDoc.getElementsByTagName("residential");
for (
i=0;i<s.length;i++)

document.write("<tr>");
document.write("<td>");
document.write(
s[i].getElementsByTagName("streetNumber")[0].childNodes[0].nodeValue);
document.write(" ");
document.write(
s[i].getElementsByTagName("street")[0].childNodes[0].nodeValue);
document.write("</td>");

document.write("<td>");
document.write(
s[i].getElementsByTagName("suburb")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>

</body>
</html> 
This is my xml file:

PHP Code:
<?xml version="1.0" ?> 
<propertyList date="2007-01-30-09:18:38" username="console" password="your account password">
<rental modTime="2007-01-30-09:18:38" status="current">
<agentID>45873232</agentID> 
<uniqueID>3</uniqueID> 
<dateAvailable>2007-01-30T09:18:38.883</dateAvailable> 
<rent period="weekly">180</rent> 
<address display="yes">
<streetNumber>65</streetNumber> 
<street>Figtree Road</street> 
<suburb>YOURTOWN</suburb> 
<state /> 
<postcode /> 
<country>Australia</country> 
</address>
<category name="House" /> 
<headline /> 
<description>
<![CDATA[ 
<P>Sundrenched Family Home  </P><P></P><P>Spacious 3 bedroom family home featuring separate lounge and dining, open plan gourmet kitchen with dishwasher and gas cooking, polished floors in the living areas, built in robes, main with walk in robe and ensuite bathroom, separate teenagers retreat or home office, single lock up garage.    </P>
]]> 
</description>
<features>
<bedrooms>4</bedrooms> 
<bathrooms>1</bathrooms> 
</features>
<objects>
<img id="m" modTime="2007-01-30-09:18:38" file="p3i2.jpg" /> 
</objects>
</rental>
<residential modTime="2007-01-30-09:18:38" status="current">
<agentID>45873232</agentID> 
<uniqueID>7</uniqueID> 
<authority value="exclusive" /> 
<price display="yes">790000</price> 
<address display="yes">
<streetNumber>182</streetNumber> 
<street>Robertson Court</street> 
<suburb>MYTOWN</suburb> 
<state /> 
<postcode /> 
<country>Australia</country> 
</address>
<category name="Townhouse" /> 
<headline>Expansive Family Residence</headline> 
<description>
<![CDATA[ 
<P>Cascading over four expansive levels, this superb wide fronted (6.1m) terrace sets a new standard in contemporary living and offers a lifestyle of comfort and convenience.   </P>
]]>  
</description>
<features>
<bedrooms>1</bedrooms> 
<bathrooms>2</bathrooms> 
<pool type="inground">yes</pool> 
</features>
<objects>
<img id="m" modTime="2007-01-30-09:18:38" file="p7i8.jpg" /> 
</objects>
</residential>
<rental modTime="2008-04-20-09:18:38" status="current">
<agentID>45873232</agentID> 
<uniqueID>4</uniqueID> 
<dateAvailable>2007-01-30T09:18:38.883</dateAvailable> 
<rent period="weekly">240</rent> 
<address display="yes">
<streetNumber>24</streetNumber> 
<street>Some Road</street> 
<suburb>ATOWN</suburb> 
<state /> 
<postcode /> 
<country>Australia</country> 
</address>
<category name="House" /> 
<headline /> 
<description>
<![CDATA[ 
<P>Supurb Family Home  </P><P></P><P>Ideal for the large family, this spacious six bedroom family home is located on five acres of lan just outside of town. All the bedrooms have built-in robes. The main bedroom has an ensuite and the other two bathrooms are located near the other rooms. The house fetures a large deck overlooking the mighty Aver River.    </P>
]]> 
</description>
<features>
<bedrooms>6</bedrooms> 
<bathrooms>3</bathrooms> 
</features>
<objects>
<img id="m" modTime="2008-04-20-09:18:38" file="p4i4.jpg" /> 
</objects>
</rental>
</propertyList>
Sketch of what I would like:

Reply With Quote