[RFC]: Use lxml to generate and manipulate XML documents

As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124* IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents. And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' / /re//sult//: // //24.12.2000 // //12.24.2000 // //key / more info: http://lxml.de/ -- Thanks and best regards! Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

Yeah, I think it is a good idea, I think we don't need any wrapper any more if we adopt this. On 2014?01?14? 12:57, Sheldon wrote:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
-- Thanks and best regards!
Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

I think it is nice to use a generic lxml library to generate XML documents. About the existing XML documents generation like vmTemplate._get_cdrom_xml(), networkxml.to_network_xml() &etc, do you have plane to convert them to use lxml library? 2014/1/14 12:57, Sheldon:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
-- Thanks and best regards!
Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

On 01/14/2014 03:33 PM, Shu Ming wrote:
I think it is nice to use a generic lxml library to generate XML documents. About the existing XML documents generation like vmTemplate._get_cdrom_xml(), networkxml.to_network_xml() &etc, do you have plane to convert them to use lxml library? not plane. will refactor these old code later.
I just use it in new my new patch. You can refactor these old code with lxml.
2014/1/14 12:57, Sheldon:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
-- Thanks and best regards!
Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center
-- Thanks and best regards! Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

I agree. lxml is a lot more friendly than libxml2, while it provides almost the same functionality. on 2014/01/14 12:57, Sheldon wrote:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

+1 to the adoption of the lxml library On 01/14/2014 05:48 AM, Zhou Zheng Sheng wrote:
I agree. lxml is a lot more friendly than libxml2, while it provides almost the same functionality.
on 2014/01/14 12:57, Sheldon wrote:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

+1 to manipulate and create xml using lxml On 01/14/2014 02:57 AM, Sheldon wrote:
As we all know there is a issue about generate and manipulate XML documents *https://github.com/kimchi-project/kimchi/issues/124*
IMO, lxml is a good choice. you can see this patch: $ git show 69edfe9 Mark use it to generate XML documents.
And for manipulate XML documents, here is a example. /$ ipython -c 'from lxml import objectify root = objectify.fromstring("<root><a k=\"key\">24.12.2000<b>12.24.2000</b></a></root>") print root.a print root.a.b print root.a.get("k") ' /
/re//sult//: // //24.12.2000 // //12.24.2000 // //key /
more info: http://lxml.de/
-- Thanks and best regards!
Sheldon Feng(???)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center
participants (6)
-
Aline Manera
-
Daniel H Barboza
-
Royce Lv
-
Sheldon
-
Shu Ming
-
Zhou Zheng Sheng