0

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>
Pointy
  • 389,373
  • 58
  • 564
  • 602
  • See http://stackoverflow.com/questions/649614/xml-parsing-of-a-variable-string-in-javascript for parsing XML – Manse Jun 18 '12 at 13:50

1 Answers1

1
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!
    }
}
Florian Margaine
  • 54,552
  • 14
  • 89
  • 116