XML read and write using Lib CMarkup
Dear All!
i really need your helping, how to read and write XML in using CMarkup.h and CMarkup.cpp?
for example input XML file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<start>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
<text>xxxxxx</text>
<src>xxxx</src>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
<text>xxxxxx</text>
<src>xxxx</src>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
<src>xxxx</src>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
</entry>
</start>
|
and output should be like here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<start>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
</entry>
<entry>
<term>xxxxxxxxxxx</term>
<term>xxxxxxxxxxxxxxx</term>
</entry>
</start>
|
because some elements(text, src, ...) should be removed,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
int main()
{
CMarkup xml;
xml.load(MSD_T("filename.xml");
while(xml.FindNode())
{
while(xml.FindElem(MSD_T("entry")))
{
if(xml.FindElem(MSD_T("text")))
xml.RemoveElem();
if(xml.FindElem(MSD_T("src")))
xml.RemoveElem();
}
}
xml.Save("output.xml");
return 0;
}
|
but actually it couldn't find second element (entry).
if you know how to write, many thanks :)
Thanks again!
Szandi
Topic archived. No new replies allowed.