Swan Lake Beta2 is here.
xml:Element e = xml`<p:e xmlns:p="http://example.com/"/>`;
// `name` will be `{http://example.com}e`.
string name = e.getName();

XML Namespaces

The goal is to support namespaces without adding complexity if you don’t use them. The ns:x qualified name in XML is expanded into {url}x where url is the namespace name bound to ns. The XML namespace declarations are kept as attributes using the standard binding of xmlns.

xml:Element e = xml`<p:e xmlns:p="http://example.com/"/>`;
string name = e.getName();

name will be {http://example.com}e.

bal run xml_namespaces.bal
xml:Element e = xml`<p:e xmlns:p="http://example.com/"/>`;
// `name` will be `{http://example.com}e`.
string name = e.getName();

XML Namespaces

The goal is to support namespaces without adding complexity if you don’t use them. The ns:x qualified name in XML is expanded into {url}x where url is the namespace name bound to ns. The XML namespace declarations are kept as attributes using the standard binding of xmlns.

xml:Element e = xml`<p:e xmlns:p="http://example.com/"/>`;
string name = e.getName();

name will be {http://example.com}e.

bal run xml_namespaces.bal

In the creation of Ballerina, we were inspired by so many technologies. Thank you to all that have come before us (and forgive us if we missed one): Java, Go, C, C++, D, Rust, Haskell, Kotlin, Dart, TypeScript, JavaScript, Python, Perl, Flow, Swift, Elm, RelaxNG, NPM, Crates, Maven, Gradle, Kubernetes, Docker, Envoy, Markdown, GitHub and WSO2.

Cookie Policy

This website uses cookies so that we can provide you with the best user experience. Read our Cookie Policy to find out more.

If you wish to disable cookies you can do so from your browser.

I Understand