ultimatepp/uppdev/XMLAttrCount/main.cpp
cxl 351994a6cc Adding uppdev....
git-svn-id: svn://ultimatepp.org/upp/trunk@328 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-08-15 08:36:24 +00:00

49 lines
No EOL
1 KiB
C++

#include <ide/Common/Common.h>
void write_out( FileOut& out, const XmlNode& xml, int ident )
{
switch( xml.GetType() )
{
case XML_TEXT:
out << String(' ', ident) << "Text: " << xml.GetText() << "\n";
break;
case XML_TAG:
out << String(' ', ident) << "Tag: " << xml.GetTag() << "\n";
for ( int i = 0, total = xml.GetAttrCount(); i < total; i++ )
{
out << String( ' ', ident ) << "+> " << xml.AttrId(i) << ": " << xml.Attr(i) << "\n";
}
ident += 2;
break;
case XML_DOC:
out << String(' ', ident) << "Doc:\n";
break;
default:
out << String(' ', ident) << "**UNDEFINED TAG**\n";
break;
}
for ( int i = 0, total = xml.GetCount(); i < total; i++ )
{
write_out(out, xml[i], ident + 2);
}
}
GUI_APP_MAIN
{
Package p;
String filename("D:\\uppsrc\\ide\\Common\\Common.upp");
p.Load(filename);
XmlNode xml;
XmlNode& makefile = xml.Add("makefile");
XmlNode& lib = makefile.Add("lib");
lib.SetAttr("id", GetFileName(filename));
FileOut out("e:\\tst.dat");
write_out(out, xml, 2);
}