TQS Home
Trivia Quiz Shell Version 2.8 Now Available!Bot Productions Home
TQS 2.5

Back to Reference

xmlGetText Function

Returns the text contents of an XML element.

value = xmlGetText(el, defVal);

XML element object whose contents are to be retrieved.
The value to return if the element does not exist or is empty.

Returns the contents of the element, or defVal if the element does not exist or is empty.


Using this function instead of the text property of XML element objects allows you to handle a default value if the element does not exist.


  <FOO>Custom Foo Contents</FOO>
spanFoo.innerText = xmlGetText(xmlChildOf(
  xmlLocData, "FOO", 0), "Default FOO contents.");
spanBar.innerText = xmlGetText(xmlChildOf(
  xmlLocData, "BAR", 0), "Default BAR contents.");

The HTML element spanFoo will contain Custom Foo Contents, while the element spanBar will contain Default Bar Contents.

©2016 Bot Productions. All rights reserved.Last Updated: September 9, 2007