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?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Vanarajan
  • 973
  • 1
  • 10
  • 35
  • Could you use XPath? http://stackoverflow.com/questions/13703478/xsl-xpath-expression-to-check-if-a-node-contains-at-least-one-non-empty-child – cmbuckley Jun 06 '15 at 16:07

1 Answers1

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");
  }
Harry
  • 87,580
  • 25
  • 202
  • 214
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501