Reputation: 6057
Sometimes code says more then words, so the following lines work:
$("#text11").append($(xml).find("address").find("street"));
$("#<%= tbWoonplaats.ClientID %>").val('testing?');
but these do not:
var street = $(xml).find("address").find("street");
$("#<%= tbAdres.ClientID %>").val(street);
it displays [object object] in the input
now i've tried to replace .val(street);
with .val(new string(street));
but that doesn't work either
appending to a span works but setting with .val()
to input doesn't...
<span id="text11"></span>
EDIT the output of
var street = $(xml).find("address").find("street");
window.alert(street);
is: [object Object]
Upvotes: 6
Views: 29133
Reputation: 322592
Try this:
var street = $(xml).find("address").find("street").text();
You were getting the node with .find("street")
, but not its content, so you needed .text()
.
EDIT:
You can check to see if a street
node was found using the length
property.
var street = $(xml).find("address").find("street");
alert(street.length); // should alert at least 1 if the find was successful
Upvotes: 5
Reputation: 65284
try..
$("#<%= tbAdres.ClientID %>").val(street.html());
or
$("#<%= tbAdres.ClientID %>").val(street.text());
Upvotes: 0