Add an element "foo" to the document foo = document << "foo" # Set attribute "attr" on foo foo["attr"] = "la" # Set another attribute in a different namespace foo["attr", "namespace"] = "too" # Swap foo into another namespace foo.namespace = "blah" # Add a couple of element nodes to foo foo << "a" foo << "b" # Access the children of foo in various ways a = foo[0] foo.each { |child|
#...
} # Add text to foo # Add instruction # Add comment # Get the root of the document document == a.root # Write the document out puts document.to_s
Classes and Modules |