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.

Syntax
value = xmlGetText(el, defVal);
Parameters

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

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

Remarks

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.

Example

<CUSTOM_FOO>
  <FOO>Custom Foo Contents</FOO>
</CUSTOM_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.

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