lib/edit_xml.cf
edit_xml bundles
xml_insert_tree_nopath
Prototype: xml_insert_tree_nopath(treestring)
Description: Insert XML tree with no path
This edit_xml
bundle inserts the given XML tree. Use with an
empty XML document.
Arguments:
treestring
: The XML tree, as a string
Example:
files:
"/newfile" edit_xml => xml_insert_tree_nopath('<x>y</x>');
Implementation:
bundle edit_xml xml_insert_tree_nopath(treestring)
{
insert_tree:
'$(treestring)';
}
xml_insert_tree
Prototype: xml_insert_tree(treestring, xpath)
Description: Insert XML tree at the given XPath
This edit_xml
bundle inserts the given XML tree at a specific
XPath. Uses insert_tree
.
Arguments:
treestring
: The XML tree, as a stringxpath
: A valid XPath string
Example:
files:
"/file.xml" edit_xml => xml_insert_tree('<x>y</x>', '/a/b/c');
Implementation:
bundle edit_xml xml_insert_tree(treestring, xpath)
{
insert_tree:
'$(treestring)' select_xpath => "$(xpath)";
}
xml_set_value
Prototype: xml_set_value(value, xpath)
Description: Sets or replaces a value in XML at the given XPath
This edit_xml
bundle sets or replaces the value at a specific
XPath with the given value. Uses set_text
.
Arguments:
value
: The new valuexpath
: A valid XPath string
Example:
files:
"/file.xml" edit_xml => xml_set_value('hello', '/a/b/c');
Implementation:
bundle edit_xml xml_set_value(value, xpath)
{
set_text:
"$(value)"
select_xpath => "$(xpath)";
}
xml_set_attribute
Prototype: xml_set_attribute(attr, value, xpath)
Description: Sets or replaces an attribute in XML at the given XPath
This edit_xml
bundle sets or replaces an attribute at a specific
XPath with the given value. Uses set_attribute
.
Arguments:
attr
: The attribute namevalue
: The new attribute valuexpath
: A valid XPath string
Example:
files:
"/file.xml" edit_xml => xml_set_attribute('parameter', 'ha', '/a/b/c');
Implementation:
bundle edit_xml xml_set_attribute(attr, value, xpath)
{
set_attribute:
"$(attr)"
attribute_value => "$(value)",
select_xpath => "$(xpath)";
}