Parse XML through JavaScript and get node value -
my code this
var tariffdate = pricesheet.children('tariffeffdate')[1].text; where expect data inside tariffeffdate tag. gives me undefined instead.
i can <tariffeffdate>1999-01-01t00:00:00</tariffeffdate> result code
console.log(pricesheet.children('tariffeffdate')[1]) but when add .text data inside node giving me undefined. can point out doing wrong here?
you need use node.nodevalue instead of .text.
.children('tariffeffdate')[1] give htmlelement inherits node, won't give leaf node, meaning htmlelement might have multiple children. why cannot value of (technically) multiple child-nodes. can access first node calling node.firstchild.
essentially, want final code be:
var tariffdate = pricesheet.children('tariffeffdate')[1].firstchild.nodevalue;
Comments
Post a Comment