Graphic Design Forum and Web Design Forum  

Go Back   Graphic Design Forum and Web Design Forum »Web Design Forum »Programming Forum

Notices

Programming Forum Web and Software Programming Forum - Java, PHP, SQL etc.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 14-05-2008, 08:16 AM
Bendy's Avatar
Junior Member
 
Join Date: May 2008
Posts: 8
Default Xml - Reaxml

Hi all,

This is my first post for help on an issue.

I have a friend who has just installed the Console Realestate software, it exports an xml file in the reaxml file format (a sample export is attached).

What I want to do is create a website that looks in the xml file for the property details. I will have seperate pages for Residential Sales, Residential Rentals, Commercial Sales, Commercial Rentals and Vacant Land.

I have had a few attempts using javascript but it doesn't seem to work.

Any help that you could provide would be greatly appreciated.

Cheers,

Ben
XML SAMPLE: (saved as export.xml)

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>
</propertyList>



Last edited by Bendy; 14-05-2008 at 11:51 PM. Reason: Edited to include corrected code
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #2 (permalink)  
Old 14-05-2008, 08:19 AM
Bendy's Avatar
Junior Member
 
Join Date: May 2008
Posts: 8
Default Code

Hi all

I obviously did something wrong in that post.

Attached is the file in text format

Cheers

Ben
Attached Files
File Type: txt xml-export.txt (2.1 KB, 2 views)
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #3 (permalink)  
Old 14-05-2008, 09:32 AM
Toon's Avatar
Netvibes is an Addiction™
 
Join Date: Jan 2007
Location: Sheffield, UK
Gender: Male
Posts: 17,273
Default

Wrap the code in PHP tags to make it visible (see above)
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #4 (permalink)  
Old 14-05-2008, 02:30 PM
Member
 
Join Date: May 2008
Location: Yorkshire, England
Gender: Male
Posts: 99
Default

You're not going to be able to do anything with that as it is not valid XML.

For example at line 30 you have a < /rental> tag but there was no < rental> start tag (spaces are there due to forum formatting).

Have you edited the output in any way? If you haven't then ask for your money back as it isn't doing what it should be.

How much has your friend paid for this software?

Regards

Carl

Last edited by Scriptage; 14-05-2008 at 02:32 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #5 (permalink)  
Old 14-05-2008, 11:55 PM
Bendy's Avatar
Junior Member
 
Join Date: May 2008
Posts: 8
Default

Carl,

you are correct - I have edited the code. I have uploaded the incorrect file by mistake. I have edited my first post to include the correct code. I had edited a couple of the field names to see if that would make any difference, but it didn't.

The DTD that it is formatted against is avaiable at http://reaxml.realestate.com.au/propertyList.dtd

Thank you for your help

Ben
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #6 (permalink)  
Old 15-05-2008, 02:26 AM
Bendy's Avatar
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:

Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #7 (permalink)  
Old 16-05-2008, 04:06 PM
Member
 
Join Date: May 2008
Location: Yorkshire, England
Gender: Male
Posts: 99
Default

For the love of God don't use Javascript to transform XML. You need to be using XSLT:

real.xls:

PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" 
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>
   <xsl:template match="rental">
       <div class="table">
           <div class="heading"><xsl:value-of select="address/suburb" />: <xsl:value-of select="address/streetNumber" /> <span class="street"><xsl:value-of select="address/street" /></span></div>
 
    <div class="house">
  <xsl:element name="img">
  <xsl:attribute name="src"><xsl:value-of select="object/img/@file" /></xsl:attribute>
  <xsl:attribute name="alt">Picture of the house</xsl:attribute>
  </xsl:element>
  <p>Bedrooms: <xsl:value-of select="features/bedrooms" /></p>
  <p>Bathrooms: <xsl:value-of select="features/bathrooms" /></p>
  <p>Carports: <xsl:value-of select="features/carports" /></p>
  
    </div>
    <div class="rent">
    $ <xsl:value-of select="rent" /> pw
       <div class="description"><xsl:value-of select="description" /></div>
    <span class="details">
  <xsl:element name="a">
   <xsl:attribute name="href"><![CDATA[http://www.yoursite.com/cgi-bin/prog.pl?get=house&id=]]><xsl:value-of select="uniqueID" /></xsl:attribute>
   <xsl:attribute name="title">Property details</xsl:attribute>
  Details
  </xsl:element>

    </span>

    </div>
    <div class="agent">
  <xsl:element name="a">
   <xsl:attribute name="href"><![CDATA[http://www.yoursite.com/cgi-bin/prog.pl?get=agent&id=]]><xsl:value-of select="agentID" /></xsl:attribute>
   <xsl:attribute name="title">Property details</xsl:attribute>
  Agent Details
  </xsl:element>

    </div>

       </div>
   </xsl:template>
   <xsl:template match="residential">
   </xsl:template>

   <xsl:template match="/">
   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
  <title>Real Estate</title>
         <link rel="stylesheet" type="text/css" href="real.css" />
      </head>
      <body>
      <xsl:apply-templates />
      </body>
   </html>

   </xsl:template>
</xsl:stylesheet>
real.css:

PHP Code:
.table{
width:700px;
height200px;
}
.
heading{
clear:both;
}
.
street{
padding-left:5px;
}

.
house{
float:left;
}
.
rent{
float:left;
padding-left10px;
}
.
description{
overflowhidden;
width300px;
height:98px;

real.xml:

PHP Code:
<?xml version="1.0" ?>
<?xml
-stylesheet type="text/xsl" href="real.xsl"?>
<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>



Note the reference to the stylesheet at the top of the xml document.

I've left the css pretty simple just so you get the general idea of what to do and so that you can style it to your requirements.

If you have any questions let me know ;)

Regards

Carl

Last edited by Scriptage; 16-05-2008 at 04:09 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #8 (permalink)  
Old 17-05-2008, 12:52 PM
Bendy's Avatar
Junior Member
 
Join Date: May 2008
Posts: 8
Default Thank You

Quote:
Originally Posted by scriptage View Post
For the love of God don't use Javascript to transform XML. You need to be using XSLT:
Thank you Carl.

A friend that also runs a hosting business told me the same thing. Unfortuently neither of us have had a lot to do with xml though.

Is there another way, rather than using a style sheet.
There are two reasons that I ask this:
1. I will have to manually add the link to the xsl file each time it is uploaded, and
2. I want to be able to have some sort of way of only displaying a certain category, eg. just rentals or just residential sales.

Also is there a way to add search functionality, such as by price range (either selling price or rent per week depending on type selected) and also on other attributes such as bedrooms and bathrooms and if it has a pool or not

Thank you so much,

I will be trying google but I am about to leave

Cheers,

Ben
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #9 (permalink)  
Old 17-05-2008, 01:38 PM
Member
 
Join Date: May 2008
Location: Yorkshire, England
Gender: Male
Posts: 99
Default

Hi Ben,

The stylesheet in the above post filters by rental (I assumed this is what you wanted to do from looking at your sketch).

The only way to do what you require is to use a server side programming language; it would be easy to do using .NET and possible with PERL, it all depends on what your server can handle, i.e., if you are hosted o