xmlsource

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL