I have this code:
$.ajax({
type: "GET",
url: trgUrl,
success: function (data)
{
var xml= $.parseXML(data);
{
var obj= $.xml2json(xml);
//....
}
});
and data can be somthing like:
"<name> Mike </name>"
now, the problem is that after using $.xml2json(xml), in order to show the name i need to write:
alert(obj.name.value); // Mike
instead of just:
alert(obj.name); // object object
in other words: the $.xml2json turns the content of <name> into another object (instead of making it a direct string)
How can i fix that behavior? does anybody had this problem ?
Modify plugin as follows:
DEMO: http://jsfiddle.net/ycN37/
If nodes have child nodes this can create problems which is likely why author created object in first place