1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
# Content : an empty root element
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?><root/>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Element,"new","new content")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><new>new content</new></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Attribute,"new","foo")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root new="foo"/>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::PI,"newPI","PIcontent")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><?newPI PIcontent?></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Comment,"","comment content")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><!--comment content--></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Text,"","text content")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root>text content</root>
#
# Content : a little structure.
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/b/@att1",BDB::XML::Modify::Remove,BDB::XML::Modify::None)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att2="att2">b content 1</b><b att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/b[text()='b content 2']",BDB::XML::Modify::Remove,BDB::XML::Modify::None)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/comment()",BDB::XML::Modify::Remove,BDB::XML::Modify::None)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
</root>
#
# BDB::XML::Modify.new("/root/a/text()",BDB::XML::Modify::Remove,BDB::XML::Modify::None)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1"/>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Element,"new")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--><new/></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Element,"new","",0)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><new/><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Append,BDB::XML::Modify::Element,"new","",2)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<new/><b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/a",BDB::XML::Modify::InsertBefore,BDB::XML::Modify::Element,"new")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><new/><a att1="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/a",BDB::XML::Modify::InsertAfter,BDB::XML::Modify::Element,"new")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att1="att1">a content</a><new/>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/a",BDB::XML::Modify::Rename,BDB::XML::Modify::None,"x")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><x att1="att1">a content</x>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/a/@att1",BDB::XML::Modify::Rename,BDB::XML::Modify::None,"att2")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a att2="att1">a content</a>
<b att1="att1" att2="att2">b content 1</b>
<b att1="att1" att2="att2">b content 2</b>
<!--comment--></root>
#
# Content test update
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a>a content 1<c/>a content 2</a>
<b>b content 1</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/comment()",BDB::XML::Modify::Update,BDB::XML::Modify::None,"","new comment")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a>a content 1<c/>a content 2</a>
<b>b content 1</b>
<!--new comment--></root>
#
# BDB::XML::Modify.new("/root/a",BDB::XML::Modify::Update,BDB::XML::Modify::None,"","new a text")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a><c/>new a text</a>
<b>b content 1</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root/a",BDB::XML::Modify::Update,BDB::XML::Modify::None)
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a><c/></a>
<b>b content 1</b>
<!--comment--></root>
#
# BDB::XML::Modify.new("/root",BDB::XML::Modify::Update,BDB::XML::Modify::None,"","new root text")
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a>a content 1<c/>a content 2</a>
<b>b content 1</b>
<!--comment-->new root text</root>
#
# BDB::XML::Modify.new("/root/b",BDB::XML::Modify::Update,BDB::XML::Modify::None,"","new b text")
#
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<root><a>a content 1<c/>a content 2</a>
<b>new b text</b>
<!--comment--></root>
#
|