I searched for this for an hour and cannot find the answer.
I use $(xml).find('title')- but it seems to return all the "headers" in all nodes. How to simply get the title in the root directory of a node?
<response stat="OK">
<title>Some Document</title>
<menu>
<item>
<title>Some Title</title>
<url>/</url>
</item>
<item>
<title>Some Title 1</title>
<url>/asdfasdf/</url>
</item>
</menu>
</response>
returns "Some DocumentSome TitleSome Title 1"
$.ajax({
dataType: 'xml',
url: 'someurl',
success: function(data, textStatus, XMLHttpRequest) {
console.log($(data).find('title').text());
}
I just want the first title! I would prefer not to use xpath, I would prefer to use the cheapest solution.
source
share