Sample code for 30+ languages & platforms
Rust

NewChild using a Tag Path

Demonstrates calling NewChild with a tag path.

This example requires Chilkat v9.5.0.64 or greater.

Chilkat Rust Downloads

Rust
let xml = chilkat::Xml::new();

xml.set_tag("world");

// This example uses features introduced in v9.5.0.64
let x_frisco = xml.new_child("north_america|united_states|california|san_francisco", "Silicon Valley").unwrap();
let _ = x_frisco.add_attribute("landmark", "Golden Gate Bridge");

println!("{}", xml.get_xml().unwrap_or_default());

// Produces the following XML
// 
// 	<?xml version="1.0" encoding="utf-8" ?>
// 	<world>
// 	    <north_america>
// 	        <united_states>
// 	            <california>
// 	                <san_francisco landmark="Golden Gate Bridge">Silicon Valley</san_francisco>
// 	            </california>
// 	        </united_states>
// 	    </north_america>
// 	</world>