leforestier / yattag

Python library to generate HTML or XML in a readable, concise and pythonic way.
333 stars 31 forks source link

Can I use yattag to modify XML files? #35

Closed rn4n closed 7 years ago

rn4n commented 7 years ago

Consider this XML:

<?xml version="1.0" encoding="utf-8"?>
<tests>
    <test name="foo">
        <result>result-foo</result>
    </test>
    <test name="bar">
        <result>result-foo</result>
    </test>
</tests>

Is possible to use yattag to load this XML and change the content from a specific node with name attribute?

leforestier commented 7 years ago

Hi,

no, yattag is just a fast way of producing xml strings, but it doesn't keep all the nodes of a document in memory. There is no way to load a XML document with yattag and modify it. For what you're trying to do, I'd use pyquery, I find it very easy to use: https://pythonhosted.org/pyquery/ .

rn4n commented 7 years ago

@leforestier I'll try it, cheers.