コード例 #1
0
ファイル: TestXMLFragment.py プロジェクト: kstaken/Syncato
 def testRemoveNode(self):
     # create a tree then remove the child
     doc = XMLFragment()
     doc.addNode("/root/child")
     doc.removeNode("/root/child")
     
     self.assertEqual(doc.serialize(), '<?xml version="1.0"?>\n<root/>\n')
     
     # create a tree then remove the second child
     doc = XMLFragment()
     doc.addNode("/root/child")
     doc.addNode("/root/child")
     doc.removeNode("/root/child[2]")
     
     self.assertEqual(doc.serialize(), '<?xml version="1.0"?>\n<root><child/></root>\n')
コード例 #2
0
ファイル: TestXMLFragment.py プロジェクト: kstaken/Syncato
 def testRemoveNodeNs(self):
     namespaces = {'t': "test", 's': "test2"}
     
     # Test deleting a node that's in a namespace                
     doc = XMLFragment()
     #doc.registerNamespaces(namespaces)
     
     doc.addNode("/root/t:child")
     doc.removeNode("/root/t:child")
     
     self.assertEqual(doc.serialize(), '<?xml version="1.0"?>\n<root xmlns:t="test"/>\n')
     
     # create a tree then remove the second child
     doc = XMLFragment()
     #doc.registerNamespaces(namespaces)
     
     doc.addNode("/root/t:child")
     doc.addNode("/root/t:child")
     doc.removeNode("/root/t:child[2]")
     
     self.assertEqual(doc.serialize(), '<?xml version="1.0"?>\n<root xmlns:t="test"><t:child/></root>\n')