Skip to content

Instantly share code, notes, and snippets.

@jb55
Created September 4, 2010 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jb55/564924 to your computer and use it in GitHub Desktop.
Save jb55/564924 to your computer and use it in GitHub Desktop.
int main(int argc, const char *argv[])
{
if (argc != 2) {
printf("Usage: xml_test <filename>\n");
return 1;
}
{
DataReader dataReader(argv[1]);
auto items = dataReader.getData();
items->forEach([](Data* item) {
std::cout << "[" << item->asString() << "] " << std::endl <<
" name: " << item->get("name")->asString() << std::endl <<
" description: " << item->get("description")->asString() << std::endl <<
" power: " << item->get("power")->asFloat() << std::endl;
});
}
return 0;
}
//===----------------------------------------------------------------------===//
// The data
//===----------------------------------------------------------------------===//
/*
<?xml version="1.0" ?>
<items>
<item name="Item #1" description="This is the best item because it's number 1"/>
<item name="Cool Item" description="This is a cool item" power="2.0"/>
</items>
*/
//===----------------------------------------------------------------------===//
// The output
//===----------------------------------------------------------------------===//
/*
[item]
name: Item #1
description: This is the best item because it's number 1
power: 0
[item]
name: Cool Item
description: This is a cool item
power: 0
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment