Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering XML

Status
Not open for further replies.

Bakunin

Programmer
Dec 21, 2000
31
GB
Hi,
I am tring to put together a simple XML based search engine. At the moment this is a cimbination of a XML file and some ASP to load and check the contents of the MXL for matches.

However I would like to somehow filter the data in the XML based on the search criteria entered by a user. so for example, if I searched on the keyword Error on the URL elements it would create XML with only one element:

<CODE>
<SOURCE ID=&quot;1&quot;>
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO CONNECTION OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>connection</URL>
<DESCRIPTION>Simple Source for a generic ADO connection to SQL Server</DESCRIPTION>
</SOURCE>
<SOURCE ID=&quot;2&quot;>
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO COMMAND OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>command</URL>
<DESCRIPTION>Simple Source for a generic ADO command with parameterised query variables</DESCRIPTION>
</SOURCE>
<SOURCE ID=&quot;3&quot;>
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ERROR MODULE</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>Error</URL>
<DESCRIPTION>Source for a generic Error Module</DESCRIPTION>
</SOURCE>
</CODE>

I have tried a number of implementations.

1. Trying to use selectnode on the xml file. The problem here is syntax, I have tried everything I know to date with constant failure.

2. Try a conditional select in the XSL file. I hardcoded values into the XSL which worked.
<xsl:for-each select=&quot;CODE/SOURCE[URL$lt$'Error']&quot;>
<tr>
<td bgcolor = &quot;Yellow&quot;><xsl:value-of select=&quot;URL&quot;/></td>
<td bgcolor = &quot;Yellow&quot;><xsl:value-of select=&quot;DESCRIPTION&quot;/></td>
</tr>
</xsl:for-each>

However I don't know how to pass parameters ( the search string ) to XSL, or how to search for the occurence of the search string in a larger string ( similar to VB inst function )

Any help on any of these issues is greatly appreciated.

Lenin.
 
Off the top of my head, you need to get parameters out of the url (i.e. converting &quot;mypage.php?value=dog&quot; to &quot;dog,&quot; then comparing the value (&quot;dog&quot;) to the various fields in your XML.

The first part involves getting the url and then splitting it apart. Unfortunately, I don't know enough XSL to tell you how to do that.

Rose/Miros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top