#!/usr/bin/env fun /* * This file is part of the Fun programming language. * https://fun-lang.xyz/ * * Copyright 2025 Johannes Findeisen * Licensed under the terms of the Apache-2.0 license. * https://opensource.org/license/apache-2-0 * * Added: 2025-12-09 */ /* * Access a namespaced XML file and show prefixed element names. */ include path = "./examples/data/ns_example.xml" xml = XML() doc = xml.from_file(path) if (doc == 0) print("Failed to load: ") print(path) else root = xml.root(doc) // With namespaces, the node name may include the prefix, e.g., "ns:library" print("Root element: ") print(xml.name(root)) content = read_file(path) // Extract first book title and author (namespace prefix bk:) b1 = xml.between(content, "") title = xml.between(b1, "", "") author = xml.between(b1, "", "") print("First book title: ") print(title) print("Author: ") print(author)