[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help XML Pattern Matching

  • To: xml-dev@l...
  • Subject: Help XML Pattern Matching
  • From: "Semana, Erwin" <erwin.semana@i...>
  • Date: Tue, 19 Feb 2002 17:08:13 +0800
  • Importance: high

xml pattern matching
Hi,
	Need help on why i cant get result with this synthax. Highlighted in
red.

Appreciate any help!

	
<html>
<head>
	<title>Partial Text Search</title>
<xml id='courselist' src="/XML Training/Demos/DOM Tree/courses.xml"></xml>

<script language="javascript">
var theXML, myNodeList, textToSearch;
var strNode = "";
var matches=0;

function showMatches() {

	theXML = courselist.XMLDocument;
	textToSearch = document.forms[0].searchtext.value;
	myNodeList = theXML.selectNodes('course');
	
	strNode += "<table border='1'><tr><th>Course
Title</th><th>Topics</th>";
	strNode += "<th>Course
Length</th><th>Location</th><th>Description</th></tr>";
	
	//alert(strNode);
	alert(myNodeList.length);
	
	for (var count=0; count<myNodeList.length; ++count) {
		theItem = myNodeList(count);		
		 alert(theItem.text);
		if (theItem.text.match(textToSearch)) {
			
			//Build a row with a pink background for matching
rows
			strNode += "<tr bgcolor=#ffcccc>";
			++matches;
		} else {
			//Build a row with a white background for
non-matching rows
			strNode += "<tr>";
		}
		strNode += "<td>" + theItem.childNodes[0].text + "</td>"
		strNode += "<td>" + theItem.childNodes[1].text + "</td>";
		strNode += "<td>" + theItem.childNodes[2].text + "</td>";
		strNode += "<td>" + theItem.childNodes[3].text + "</td>";
		strNode += "<td>" + theItem.childNodes[4].text +
"</td></tr>";
	}
	strNode += "</table>";
	strNode += "<h3>Number of matches: " + matches + "</h3>";
	strNode += "Press your reload button to try another search.";
	dataTarget.innerHTML = strNode;
}

</script>
</head>
<body>

<div align="center" id="dataTarget">
<form>
	<h2>Course Information Search</h2>
	Please enter a value to search for in our course list<br> 
	(partial queries OK): <input name="searchtext"><br><br>
	<input type="Button"
       value="Search the XML Document"
       onClick="showMatches()">
</form>
</div>

</body>
</html>
		


Thanks & BR;
~erwin s.


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.