$output .="<keyword>".$_POST['keyword']."</keyword><name>".$row['url']."</name><occur>".$row['occurrences']."</occur><queryTime>".(substr($end_time-$start_time,0,5))."</queryTime>";
}
I want to check in Flex, if the value of name is null or not. I tried for these, but i am not getting any alert when the node value is empty.
event.result.attribute("name").value < 0
event.result.attribute("name").length < 0
event.result.loginsuccess.name = ""
Can anyone Help me out, Here is my flex code below.
if(keyword.text == "")
{
Alert.show("Please enter the search term");
} else if(event.result.attribute("name").length < 0) {
Alert.show("No search Results"); }
else {
subtitle.text = "Search results for " + event.result.loginsuccess.keyword[0];
query.text = "query executed in " + event.result.loginsuccess.queryTime[0] + " Seconds";
}
}
check this
event.result.loginsuccess.name[0] == null
why?
because when you call a child directly on XML it always returns as XMLList so we should check that if XMLList has any child. The [0] (first index) tries to return the first child if exists othwerwise returns null
in your example it should be :
if(event.result.name[0])
{
...
}
because the name is an element not attribute, if name was attribute then it should be
if(event.result.@name[0])
{
...
}
i hope it helps
EDIT
pls try this way
if(keyword.text == "")
{
Alert.show("Please enter the search term");
} else if(!XML(event.result).name[0]) {
Alert.show("No search Results"); }
else {
subtitle.text = "Search results for " + event.result.loginsuccess.keyword[0];
query.text = "query executed in " + event.result.loginsuccess.queryTime[0] + " Seconds";
}
}
Can also check for empty string e.g.
if(event.result.name=="")
{
}