【发布时间】:2010-04-12 12:05:13
【问题描述】:
考虑以下 XML 文件:
<cookbook>
<recipe xml:id="MushroomSoup">
<title>Quick and Easy Mushroom Soup</title>
<ingredient name="Fresh mushrooms"
quantity="7"
unit="pieces"/>
<ingredient name="Garlic"
quantity="1"
unit="cloves"/>
</recipe>
<recipe xml:id="AnotherRecipe">
<title>XXXXXXX</title>
<ingredient name="Tomatoes"
quantity="8"
unit="pieces"/>
<ingredient name="PineApples"
quantity="2"
unit="cloves"/>
</recipe>
</cookbook>
假设我想解析这个文件并将每个配方收集为 XML,每个配方作为一个单独的 QString。
例如,我想要一个 QString 包含:
<recipe xml:id="MushroomSoup">
<title>Quick and Easy Mushroom Soup</title>
<ingredient name="Fresh mushrooms"
quantity="7"
unit="pieces"/>
<ingredient name="Garlic"
quantity="1"
unit="cloves"/>
</recipe>
我怎么能这样做?你们知道执行此操作的快速且干净的方法吗?
提前感谢您的帮助!
【问题讨论】:
标签: xml string qt parsing tostring