Jump to content

Selecting values from XML file using wildcards


oconndav

Recommended Posts

Hi,I hoping this is a fairly simple request but I have not been able to find a solution anywhere...I am trying to execute the if statement below so that it executes if the value of "firstname" begins with the letter A. I had hoped that adding the * wildcard would do the trick but no luck.Basically I have this running inside a loop which goes through the complete XML file, I want it to only process values begining with certain letters.If anyone coudl help me out it would be much appreciated.

aa=x[i].getElementsByTagName("firstname")	bb = aa[0].firstChild.data	if (bb=="A*")		{

Link to comment
Share on other sites

The real question is how find if any string starts with another. I don't know if JS has a function explicitly for that, but you should be able to do it with match() like so:

if (bb.match("^A.*"))

It's probably not the most efficient way, but it should work non the less.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...