Example Schema: XML with xmldatasetlevel

This example shows how you can import records from an XML document that may be nested in other tags. If the XML you're importing is created by another program and nested in some other tags, then you can use the xmldatasetlevel specifier to declare how deep the dataset tag is.

With the following schema:

table accounts
xmldatasetlevel 3
field acctno varchar export/personnel/accounts/account@acctno ''
field first varchar export/personnel/accounts/account/firstName ''
field last varchar export/personnel/accounts/account/lastName ''
field balance float export/personnel/accounts/account/balance 0

Importing the following XML document:

<?xml version="1.0" encoding="utf-8"?>
      <account acctno="12345">
      <account acctno="67890">
      <account acctno="13579">

Will get you the same data as before. Instead of the 1st tag (<export>) being regarded as the dataset and seeing a single record (<personnel>), it will instead see the 3-deep tag as the dataset (accounts) and three <account> records (which is what we want).

Copyright © Thunderstone Software     Last updated: May 19 2023
Copyright © 2023 Thunderstone Software LLC. All rights reserved.