Reputation: 3
Hi Iam a beginner in XML and javascript. But I want to select a node that contains "insurance will". I want to do this because there are nodes with same node name that can contain different text. The XML file can look like this.
<Description>Hi hello</Description>
<Description>insurance will</Description>
<Description>come here</Description>
<Description>lalaland</Description>
Upvotes: 0
Views: 1051
Reputation: 60717
var descs = document.getElementsByTagName( 'Description' );
for ( var i = 0, len = descs.length; i < len; i++ ) {
if ( descs[ i ].textContent === 'insurance will' ) {
// This node is the right one!
}
}
Upvotes: 1