The SaxIterator class provides a SAX iterator for XML data based on libxml2
More...
#include <QC_SaxIterator.dox.h>
|
| constructor (string xml, string element_name, *hash opts) |
| creates a new SaxIterator object from the XML string and element name passed More...
|
|
| copy () |
| Returns a copy of the current object (the copy will be reset to the beginning of the XML string) More...
|
|
auto | getValue () |
| returns the current value or throws an INVALID-ITERATOR exception if the iterator is invalid More...
|
|
bool | next () |
| Moves the current position to the next element in the XML string; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the XML if the XML string contains the required element. More...
|
|
| reset () |
| Reset the iterator instance to its initial state. More...
|
|
bool | valid () |
| returns True if the iterator is currently pointing at a valid element, False if not More...
|
|
The SaxIterator class provides a SAX iterator for XML data based on libxml2
◆ constructor()
Qore::Xml::SaxIterator::constructor |
( |
string |
xml, |
|
|
string |
element_name, |
|
|
*hash |
opts |
|
) |
| |
creates a new SaxIterator object from the XML string and element name passed
- Parameters
-
xml | an XML string to iterate |
element_name | the name of the element to iterate through |
opts | the following options are supported:
|
- Example:
map printf("record %d: %y\n", $#, $1), i;
The SaxIterator class provides a SAX iterator for XML data based on libxml2
Definition: QC_SaxIterator.dox.h:7
- Exceptions
-
XMLDOC-CONSTRUCTOR-ERROR | error parsing XML string |
- Since
- xml 1.4 added support for the opts argument
◆ copy()
Qore::Xml::SaxIterator::copy |
( |
| ) |
|
Returns a copy of the current object (the copy will be reset to the beginning of the XML string)
- Returns
- a copy of the current object (the copy will be reset to the beginning of the XML string)
- Example:
copy()
Returns a copy of the current object (the copy will be reset to the beginning of the XML string)
◆ getValue()
auto Qore::Xml::SaxIterator::getValue |
( |
| ) |
|
returns the current value or throws an INVALID-ITERATOR
exception if the iterator is invalid
- Returns
- the current value or throws an
INVALID-ITERATOR
exception if the iterator is invalid
- Code Flags:
- RET_VALUE_ONLY
- Example:
while (i.next()) {
printf("+ %y\n", i.getValue());
}
- Exceptions
-
INVALID-ITERATOR | the iterator is not pointing at a valid element |
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
◆ next()
bool Qore::Xml::SaxIterator::next |
( |
| ) |
|
Moves the current position to the next element in the XML string; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the XML if the XML string contains the required element.
This method will return True again after it returns False once if the XML string contains the target element, otherwise it will always return False. The iterator object should not be used after this method returns False
- Returns
- False if there are no more elements in the XML string (in which case the iterator object is invalid and should not be used); True if successful (meaning that the iterator object is valid)
- Example:
while (i.next()) {
printf(" + %y\n", i.getValue());
}
- Exceptions
-
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
◆ reset()
Qore::Xml::SaxIterator::reset |
( |
| ) |
|
Reset the iterator instance to its initial state.
Reset the iterator instance to its initial state
- Example
- Exceptions
-
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
◆ valid()
bool Qore::Xml::SaxIterator::valid |
( |
| ) |
|
returns True if the iterator is currently pointing at a valid element, False if not
- Returns
- True if the iterator is currently pointing at a valid element, False if not
- Code Flags:
- CONSTANT
- Example:
if (i.valid())
printf("current value: %y\n", i.getValue());
The documentation for this class was generated from the following file: