Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewXmlFileSource ¶
func NewXmlFileSource(filePath string) *arraysource.Model
NewXmlFileSource reads an XML file and returns an array-backed data source ready for querying with the array driver.
The XML must have a root element containing repeated child elements. Each child element becomes a row. See NewXmlSource for details on column extraction and type inference.
The table name is derived from the filename (without the extension). For example, "data/users.xml" → table name "users".
database.Query().
Model(neat.NewXmlFileSource("data/users.xml")).
Where("active = ?", true).
Get(&users)
Panics if the file cannot be opened, parsed, or has no child elements.
func NewXmlSource ¶
func NewXmlSource(xmlString string, tableName string) *arraysource.Model
NewXmlSource parses an XML string and returns an array-backed data source ready for querying with the array driver.
The XML must have a root element containing repeated child elements. Each child element becomes a row. Column values come from:
- Attributes on the child element: <user id="1"> → column "id"
- Leaf sub-elements (text-only): <name>Alice</name> → column "name"
- Nested sub-elements: stored as JSON strings (queryable via SQLite JSON)
For example:
<users>
<user id="1">
<name>Alice</name>
<active>true</active>
</user>
<user id="2">
<name>Bob</name>
<active>false</active>
</user>
</users>
Column types are inferred from string values (int, float, bool, time, string), same as the CSV source.
The table name must be provided explicitly since there is no filename to derive it from. Override with the .Table() method if needed.
database.Query().
Model(neat.NewXmlSource(xmlString, "users")).
Where("active = ?", true).
Get(&users)
Panics if the XML cannot be parsed or has no child elements.
Types ¶
This section is empty.