07-24-2023, 12:21 AM
I got a page spitting out my .xml feed/file content nicely using the easy to use ( i mean, easy to search for answers) xsl stlyesheets and a bit of xpath logic to get the 'child' photo i want and select the elements in price order ascending etc..
Now I want to link the search bar and drop down menus to dynamically query the document...
I have tried about 4000 searches on stack etc., but it seems that nobody uses XML on webpages; they just use it for fun, parse it and then never use XML dynamically.
I still don't know if I should be storing the XML in a MySQL DB (which would be a nightmare with many tables) and querying that data: I have limped here from countless searches...
I can use PHP , JQuery etc., but don't know which way to aim as there is no black and white direction to follow on forums etc.
This is my XSLT so far:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
a
<div>
<select>
<option value="a">Price To</option>
<option value="b">£100,000</option>
<option value="c">£200,000</option>
<option value="d">£300,000</option>
<option value="e">£400,000</option>
</select>
<select>
<option value="a">Price From</option>
<option value="b">£100,000</option>
<option value="c">£200,000</option>
<option value="d">£300,000</option>
<option value="e">£400,000</option>
</select>
<div id="xsltsearch">
<div class="xsltsearch_form">
<form method="post" action="properties2_1.xml">
<input name="search" type="text" class="input" value="" />
<input type="submit" class="submit" value="Search" />
</form>
</div>
</div>
</div>
<h2>Property Available </h2>
<table >
<tr bgcolor="#DCDCDC">
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<th>Picture</th>
</tr>
<xsl:for-each select="agency/branches/branch/properties/property">
<xsl:sort order="ascending" select="numeric_price" data-type="number"/>
<tr>
<td><xsl:value-of select="advert_heading"/></td>
<td><xsl:value-of select="bedrooms"/></td>
<td><xsl:value-of select="numeric_price"/></td>
<td><img src="{pictures/picture[1]/filename}" width="99px"></img></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Now I want to link the search bar and drop down menus to dynamically query the document...
I have tried about 4000 searches on stack etc., but it seems that nobody uses XML on webpages; they just use it for fun, parse it and then never use XML dynamically.
I still don't know if I should be storing the XML in a MySQL DB (which would be a nightmare with many tables) and querying that data: I have limped here from countless searches...
I can use PHP , JQuery etc., but don't know which way to aim as there is no black and white direction to follow on forums etc.
This is my XSLT so far:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
a
<div>
<select>
<option value="a">Price To</option>
<option value="b">£100,000</option>
<option value="c">£200,000</option>
<option value="d">£300,000</option>
<option value="e">£400,000</option>
</select>
<select>
<option value="a">Price From</option>
<option value="b">£100,000</option>
<option value="c">£200,000</option>
<option value="d">£300,000</option>
<option value="e">£400,000</option>
</select>
<div id="xsltsearch">
<div class="xsltsearch_form">
<form method="post" action="properties2_1.xml">
<input name="search" type="text" class="input" value="" />
<input type="submit" class="submit" value="Search" />
</form>
</div>
</div>
</div>
<h2>Property Available </h2>
<table >
<tr bgcolor="#DCDCDC">
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<th>Picture</th>
</tr>
<xsl:for-each select="agency/branches/branch/properties/property">
<xsl:sort order="ascending" select="numeric_price" data-type="number"/>
<tr>
<td><xsl:value-of select="advert_heading"/></td>
<td><xsl:value-of select="bedrooms"/></td>
<td><xsl:value-of select="numeric_price"/></td>
<td><img src="{pictures/picture[1]/filename}" width="99px"></img></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>