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>
1

1 Answer 1

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!
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

I used match("insurance will") instead of .textContent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.