| Crates.io | libxtabml |
| lib.rs | libxtabml |
| version | 0.1.1 |
| created_at | 2025-11-04 19:26:10.599662+00 |
| updated_at | 2025-11-17 21:38:18.020595+00 |
| description | Library for parsing xtabml XML files |
| homepage | |
| repository | https://github.com/consultimi/libxtabml |
| max_upload_size | |
| id | 1916838 |
| size | 616,894 |
A Rust library for parsing XtabML (Survey Table Interchange Format) files. XtabML is an XML format for describing the structure and content of survey cross-tabulation tables.
use libxtabml::{XtabMLParser, Result};
fn main() -> Result<()> {
// Parse an XtabML file
let xtab = XtabMLParser::parse_file("example.xte")?;
println!("XtabML version: {}", xtab.version);
println!("Date: {:?}", xtab.date);
println!("Number of tables: {}", xtab.tables.len());
// Access table data
for table in &xtab.tables {
println!("Table: {}", table.title);
println!(" Statistics: {:?}", table.statistic_types());
println!(" Shape: {:?}", table.shape());
// Get row and column labels
let row_labels = table.row_labels();
let col_labels = table.column_labels();
println!(" Rows: {}", row_labels.len());
println!(" Columns: {}", col_labels.len());
}
Ok(())
}
use libxtabml::XtabMLParser;
let xtab = XtabMLParser::parse_file("data.xte")?;
// Access the first table
if let Some(table) = xtab.tables.first() {
// Get all statistic types
let stat_types = table.statistic_types();
// Get data for a specific statistic (e.g., index 0 for the first statistic)
if let Some(data) = table.get_statistic_data(0) {
for (row_idx, row) in data.iter().enumerate() {
for (col_idx, value) in row.iter().enumerate() {
println!("Row {} Col {}: {:?}", row_idx, col_idx, value);
}
}
}
}
The root structure containing:
Represents a single cross-tabulation table with:
Tables store data as a matrix of cells. Each cell can contain:
<x />)Multiple statistics can be stored by interleaving rows. Use get_statistic_data() to extract data for a specific statistic type.
Add to your Cargo.toml:
[dependencies]
libxtabml = "0.1"
See LICENSE file.