forapathy
07-10-2006, 11:21 AM
I have a really big problem.. i'm using xpath in a project to parse a xml file..
the problem is.. i want to search this xml file but i can't really manage to do it..
So i'll explain:
I have the xml file.. and using flash as the interface i want to searc this file.. the problem is i'm using xpath.. but the search has to be case-sensitive..
so.. how can i do it.. this is the part of the code i can't manage to corect:
function startSearch() {
// gets search word from input text
term = this.taSearchWords.text;
if (term == "") { // if search is blank
this.errorBox.gotoAndStop(2);
}
else {// else continue on with search
menuList._visible = true;
// builds query string. this searches every tag for
// the term from the input text box (term)
var query:String = "//section/*[contains(name, "+"'"+term+"'"+")]";
// selects the nodes using contains function of XPath
myResults = XPath.selectNodes(myDoc, query);
// Converts myResults array of xml nodes to regular array
myDataSet = new Array();
for (var i = 0; i<myResults.length; i++) {
var names = XPath.selectNodes(myResults[i], "//name")[0].firstChild.nodeValue;
var desc = XPath.selectNodes(myResults[i], "//id")[0].firstChild.nodeValue;
myDataSet.push({label:names, data:desc});
}
//sends resulting array to result datalist
this.menuList.tList.dataProvider = myDataSet;
it is more that neded of the code.. but i think it is more understndable like this..
the problem is.. i want to search this xml file but i can't really manage to do it..
So i'll explain:
I have the xml file.. and using flash as the interface i want to searc this file.. the problem is i'm using xpath.. but the search has to be case-sensitive..
so.. how can i do it.. this is the part of the code i can't manage to corect:
function startSearch() {
// gets search word from input text
term = this.taSearchWords.text;
if (term == "") { // if search is blank
this.errorBox.gotoAndStop(2);
}
else {// else continue on with search
menuList._visible = true;
// builds query string. this searches every tag for
// the term from the input text box (term)
var query:String = "//section/*[contains(name, "+"'"+term+"'"+")]";
// selects the nodes using contains function of XPath
myResults = XPath.selectNodes(myDoc, query);
// Converts myResults array of xml nodes to regular array
myDataSet = new Array();
for (var i = 0; i<myResults.length; i++) {
var names = XPath.selectNodes(myResults[i], "//name")[0].firstChild.nodeValue;
var desc = XPath.selectNodes(myResults[i], "//id")[0].firstChild.nodeValue;
myDataSet.push({label:names, data:desc});
}
//sends resulting array to result datalist
this.menuList.tList.dataProvider = myDataSet;
it is more that neded of the code.. but i think it is more understndable like this..