2014-06-04 6:46 GMT-03:00 fabien leboeuf <[email protected]>:

> Hi
>
> I wish use tour python library for
>  - reading a xml file
>  - get a xml node and modify it
>
>
If you're refereing to SimpleXmlElement (in simplexml.py, inspired by the
PHP extension and based on xml.dom.minidom), the documentation is at:

https://code.google.com/p/pysimplesoap/wiki/SimpleXmlElement

i think your library is adapted but where i can find example, especially
> for reading an xml file
>
>
To create a simple xml element object based on the file contents do:

>>> from pysimplesoap.simplexml import SimpleXMLElement
>>> f = open("yourfile.xml")
>>> xml = SimpleXMLElement(f.read())
>>> print repr(xml)
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
<soap:Header><MyTestHeader
xmlns="service"><username>test</username><password>password</password></MyTestHeader></soap:Header>
<soap:Body>

</soap:Body>
</soap:Envelope>

To get a tag:

>>> xml("username")
<username>test</username>

TO add a tag:

>>> xml("MyTestHeader").add_child("foo", "bar")
<foo>bar</foo>
>>> print repr(xml)
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
<soap:Header><MyTestHeader
xmlns="service"><username>test</username><password>password</password><foo>bar</foo></MyTestHeader></soap:Header>
<soap:Body>

</soap:Body>
</soap:Envelope>

You can also use import_node method to add a complete SimpleXMLElement
inside a tag.

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
_______________________________________________
Soap mailing list
[email protected]
https://mail.python.org/mailman/listinfo/soap

Reply via email to