mirror of https://github.com/AxioDL/tinyxml2.git
adding examples to the doc
This commit is contained in:
parent
52913d12c9
commit
87e475a280
2
dox
2
dox
|
@ -184,7 +184,7 @@ SEPARATE_MEMBER_PAGES = NO
|
||||||
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
|
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
|
||||||
# Doxygen uses this value to replace tabs by spaces in code fragments.
|
# Doxygen uses this value to replace tabs by spaces in code fragments.
|
||||||
|
|
||||||
TAB_SIZE = 8
|
TAB_SIZE = 4
|
||||||
|
|
||||||
# This tag can be used to specify a number of aliases that acts
|
# This tag can be used to specify a number of aliases that acts
|
||||||
# as commands in the documentation. An alias has the form "name=value".
|
# as commands in the documentation. An alias has the form "name=value".
|
||||||
|
|
34
readme.txt
34
readme.txt
|
@ -188,6 +188,40 @@ an XML document.
|
||||||
printer.PushAttribute( "foo", "bar" );
|
printer.PushAttribute( "foo", "bar" );
|
||||||
printer.CloseElement();
|
printer.CloseElement();
|
||||||
|
|
||||||
|
<h2> Examples </h2>
|
||||||
|
|
||||||
|
<h4> Load and parse an XML file. </h4>
|
||||||
|
@verbatim
|
||||||
|
/* ------ Example 1: Load and parse an XML file. ---- */
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.LoadFile( "dream.xml" );
|
||||||
|
}
|
||||||
|
@endverbatim
|
||||||
|
|
||||||
|
<h4> Lookup information. </h4>
|
||||||
|
@verbatim
|
||||||
|
/* ------ Example 2: Lookup information. ---- */
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.LoadFile( "dream.xml" );
|
||||||
|
|
||||||
|
// Structure of the XML file:
|
||||||
|
// - Element "PLAY" the root Element, which is the FirstChildElement of the Document
|
||||||
|
// - - Element "TITLE" child of the root PLAY Element
|
||||||
|
// - - - Text child of the TITLE Element
|
||||||
|
|
||||||
|
// Navigate to the title, using the convenience function, with a dangerous lack of error checking.
|
||||||
|
const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
|
||||||
|
printf( "Name of play (1): %s\n", title );
|
||||||
|
|
||||||
|
// Text is just another Node to TinyXML-2. The more general way to get to the XMLText:
|
||||||
|
XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
|
||||||
|
title = textNode->Value();
|
||||||
|
printf( "Name of play (2): %s\n", title );
|
||||||
|
}
|
||||||
|
@endverbatim
|
||||||
|
|
||||||
<h2> Using and Installing </h2>
|
<h2> Using and Installing </h2>
|
||||||
|
|
||||||
There are 2 files in TinyXML-2:
|
There are 2 files in TinyXML-2:
|
||||||
|
|
26
xmltest.cpp
26
xmltest.cpp
|
@ -78,6 +78,32 @@ int main( int /*argc*/, const char* /*argv*/ )
|
||||||
_CrtMemCheckpoint( &startMemState );
|
_CrtMemCheckpoint( &startMemState );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ------ Example 1: Load and parse an XML file. ---- */
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.LoadFile( "dream.xml" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ Example 2: Lookup information. ---- */
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.LoadFile( "dream.xml" );
|
||||||
|
|
||||||
|
// Structure of the XML file:
|
||||||
|
// - Element "PLAY" the root Element
|
||||||
|
// - - Element "TITLE" child of the root PLAY Element
|
||||||
|
// - - - Text child of the TITLE Element
|
||||||
|
|
||||||
|
// Navigate to the title, using the convenience function, with a dangerous lack of error checking.
|
||||||
|
const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
|
||||||
|
printf( "Name of play (1): %s\n", title );
|
||||||
|
|
||||||
|
// Text is just another Node to TinyXML-2. The more general way to get to the XMLText:
|
||||||
|
XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
|
||||||
|
title = textNode->Value();
|
||||||
|
printf( "Name of play (2): %s\n", title );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
static const char* test[] = { "<element />",
|
static const char* test[] = { "<element />",
|
||||||
"<element></element>",
|
"<element></element>",
|
||||||
|
|
Loading…
Reference in New Issue