Which is the correct XML DOM statement to get the text value of the first element named 'city' in an XML document?

38. Which is the correct XML DOM statement to get the text value of the first element named "city" in an XML document?

  1. result = xmlDoc.getElementsByTagName("city")([0]).childNodes[0].nodeValue;
  2. result = xmlDoc.getElementsByTagName("city").childNodes[0].nodeValue;
  3. result = xmlDoc.getElementsByTagName("city")[0].nodeValue;
  4. result = xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue;

Answer: D) result = xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue;

Explanation:

The correct XML DOM statement to get the text value of the first element named "city" in an XML document is:

result = xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue;

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.