Created
September 4, 2010 05:16
-
-
Save jb55/564924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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