/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { String } from "../../types/java/lang/String"; import type { XmlElementHandler } from "../../types/senselogic/sitevision/api/xml/XmlElementHandler"; import type { Node } from "../../types/javax/jcr/Node"; /** * Utility interface for parsing XML. * *
* Example 1: parse a RSS XML string. *
*
* var xml = '<rss><channel><item><title>Hello World!</title></item></channel></rss>',
* parser = require('XmlParserUtil');
*
* parser.parse('/rss/channel/item', xml, function(aElement) {
* // Handle item direct instead of adding to a list in order to preserve memory!
* out.println(aElement.getElement('title').getText() + '<br>');
* });
*
*
* * Example 2: parse a ISO-8859-1 encoded RSS XML file stored in the file repository. *
*
* var xmlFile = require('ResourceLocatorUtil').getFileRepository().getNode('rss.xml'),
* parser = require('XmlParserUtil');
*
* parser.parse('/rss/channel/item', xmlFile, 'ISO-8859-1', function(aElement) {
* // Handle item direct instead of adding to a list in order to preserve memory!
* out.println(aElement.getElement('title').getText() + '<br>');
* });
*
*
* * Example 3: download and parse a remote RSS XML. *
*
* var requester = require('Requester'),
* parser = require('XmlParserUtil'),
* url = 'https://www.site.com/rss-feed.xml',
* options = {
* dataType: 'file'
* };
*
* requester.get(url, options)
* .done(function(result, statusCode, headers) {
* if (statusCode === 200 && result) {
* parser.parse('/rss/channel/item', result, function(aElement) {
* // Handle item direct instead of adding to a list in order to preserve memory!
* out.println(aElement.getElement('title').getText() + '<br>');
* });
* }
* }).fail(function(message, status) {
* // GET failed, handle appropriately
* });
*
*
*
* Important note!
* In order to protected the system against processes that consumes to much memory and to avoid
* OutOfMemoryExceptions the parsing process will be aborted and a RuntimeException thrown
* if more than 5MB of text content is found inside a single element.
*
* An instance of the Sitevision class implementing this interface can be obtained via {@link senselogic.sitevision.api.Utils#getXmlParserUtil()}.
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the Utils interface.
*