examples package: Reading a large XML file using an XML cursor
It is practical to use cursors when reading and writing large datasets, including files. The
examples package demonstrates how to use an XML cursor to read a large XML file; simply
1 2 3 4 5 6 7 8 9
examples ├── ... └── code └── xmlCursor ├── ReadLargeXmlFile.gloop └── models ├── Footer.model ├── Header.model └── Record.model
This service opens an XML cursor that reads an XML file included in the
and writes out the contents of certain elements as they're processed.
xmlCursor.ReadLargeXmlFile.gloop service will provide an output similar to that shown below:
1 2 3 4 5 6 7
[Martini] Header details are: This is the header for 1000 random people records [Martini] The name in record 1 is Wald Seys [Martini] The name in record 2 is Rolland Matthieson [Martini] The name in record 3 is Carey Nickolls ... [Martini] The name in record 1000 is Justin Whye [Martini] The trailer description is The trailer description goes here
The example service provided demonstrates how easy and fast it is to read a large XML file using an XML cursor. Not
only does Gloop read the file as a cursor (as opposed to reading the entire file to memory),
Gloop allows you to choose which elements in the file to pass on in the cursor.
This allows you to pick-and-choose which parts of a large XML file you're interested in;
element names that aren't passed into the cursor are ignored.
In the example service the
trailer element names are used.
The XML cursor provides two properties, a
string property, and a
cursor object, which is a data model representation of
the element and it's children (as shown below).
Open the service file to see comments. Make sure comments are also not hidden. ↩