storing and reading XML with commented attributes
Lets say I have an XML file like this:
Code:
[B]<root Version="1.0">[/B]
<!-- elem1 comment-->
[B]<elem1 value="foo"/>[/B]
<!-- elem2 comment-->
[B]<elem2>[/B]
<!-- elem2a comment-->
[B]<elem2a value="foo"/>[/B]
<!-- elem2b comment-->
[B]<elem2b value="foo"/>[/B]
<!-- elem2c comment-->
[B]<elem2c value="foo"/>[/B]
[B]</elem2>[/B]
<!-- elem3 comment-->
[B]<elem3 value="foo"/>
</root>[/B]
Is it possible to read this, represent it in my program, potentially modify it and write the updated structure back to disk without losing the comment <-> element connection? It's not a problem if comment must be subelements of or sth. similar, I just wanna have a consistent way of commenting elements.
Re: storing and reading XML with commented attributes
I would use QDomComment. Look at the docs. It's quite simple.