2

I am searching empty xml tag. For e.g.,

  <employee>
     <name></name>
  </employee>
  <employee>
      <name>abc</name>
   </employee>

Here how to find empty tag(name tag) using Node.js?

1

1 Answer 1

1

You have to traverse through all the relevant tags and check their content. If the content is found to be null then the tag is empty. Below is a piece of code to help you along the way.

  var emptytext=txtElement[0].childNodes[0];
  if(emptytext===null)
  {
     alert("Text is empty");
  }
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the edit. The answer is basically a transplant of the answer that the OP put in his question; see the edit history.
Oh dear. Sorry, I didn't see that.

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.