mirror of https://github.com/AxioDL/tinyxml2.git
add xmltest.h as a place to put the example docs, so they don't pollute the main file'
This commit is contained in:
parent
b9e791fa4e
commit
8871cd8437
2
dox
2
dox
|
@ -661,7 +661,7 @@ WARN_LOGFILE =
|
||||||
# directories like "/usr/src/myproject". Separate the files or directories
|
# directories like "/usr/src/myproject". Separate the files or directories
|
||||||
# with spaces.
|
# with spaces.
|
||||||
|
|
||||||
INPUT = tinyxml2.h readme.txt
|
INPUT = tinyxml2.h xmltest.h readme.txt
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||||
|
|
92
tinyxml2.h
92
tinyxml2.h
|
@ -1253,96 +1253,4 @@ private:
|
||||||
} // tinyxml2
|
} // tinyxml2
|
||||||
|
|
||||||
|
|
||||||
// What follows is the docs for the examples.
|
|
||||||
// I'd like the docs to be just before the
|
|
||||||
// actual examples in xmltest.cpp, but I
|
|
||||||
// can't seem to get doxygen to do that. It
|
|
||||||
// would be a wonderful patch if anyone figures
|
|
||||||
// it out.
|
|
||||||
|
|
||||||
/** @page Example-1 Load an XML File
|
|
||||||
* @dontinclude ./xmltest.cpp
|
|
||||||
* Basic XML file loading.
|
|
||||||
* The basic syntax to load an XML file from
|
|
||||||
* disk and check for an error. (ErrorID()
|
|
||||||
* will return 0 for no error.)
|
|
||||||
* @skip example_1()
|
|
||||||
* @until }
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @page Example-2 Parse an XML from char buffer
|
|
||||||
* @dontinclude ./xmltest.cpp
|
|
||||||
* Basic XML string parsing.
|
|
||||||
* The basic syntax to parse an XML for
|
|
||||||
* a char* and check for an error. (ErrorID()
|
|
||||||
* will return 0 for no error.)
|
|
||||||
* @skip example_2()
|
|
||||||
* @until }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @page Example-3 Get information out of XML
|
|
||||||
@dontinclude ./xmltest.cpp
|
|
||||||
In this example, we navigate a simple XML
|
|
||||||
file, and read some interesting text. Note
|
|
||||||
that this is examlpe doesn't use error
|
|
||||||
checking; working code should check for null
|
|
||||||
pointers when walking an XML tree, or use
|
|
||||||
XMLHandle.
|
|
||||||
|
|
||||||
(The XML is an excerpt from "dream.xml").
|
|
||||||
|
|
||||||
@skip example_3
|
|
||||||
@until </PLAY>";
|
|
||||||
|
|
||||||
The structure of the XML file is:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>(declaration)</li>
|
|
||||||
<li>(dtd stuff)</li>
|
|
||||||
<li>Element "PLAY"</li>
|
|
||||||
<ul>
|
|
||||||
<li>Element "TITLE"</li>
|
|
||||||
<ul>
|
|
||||||
<li>Text "A Midsummer Night's Dream"</li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
For this example, we want to print out the
|
|
||||||
title of the play. The text of the title (what
|
|
||||||
we want) is child of the "TITLE" element which
|
|
||||||
is a child of the "PLAY" element.
|
|
||||||
|
|
||||||
We want to skip the declaration and dtd, so the
|
|
||||||
method FirstChildElement() is a good choice. The
|
|
||||||
FirstChildElement() of the Document is the "PLAY"
|
|
||||||
Element, the FirstChildElement() of the "PLAY" Element
|
|
||||||
is the "TITLE" Element.
|
|
||||||
|
|
||||||
@until ( "TITLE" );
|
|
||||||
|
|
||||||
We can then use the convenience function GetText()
|
|
||||||
to get the title of the play.
|
|
||||||
|
|
||||||
@until title );
|
|
||||||
|
|
||||||
Text is just another Node in the XML DOM. And in
|
|
||||||
fact you should be a little cautious with it, as
|
|
||||||
text nodes can contain elements.
|
|
||||||
|
|
||||||
@verbatim
|
|
||||||
Consider: A Midsummer Night's <b>Dream</b>
|
|
||||||
@endverbatim
|
|
||||||
|
|
||||||
It is more correct to actually query the Text Node
|
|
||||||
if in doubt:
|
|
||||||
|
|
||||||
@until title );
|
|
||||||
|
|
||||||
Noting that here we use FirstChild() since we are
|
|
||||||
looking for XMLText, not an element, and ToText()
|
|
||||||
is a cast from a Node to a XMLText.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif // TINYXML2_INCLUDED
|
#endif // TINYXML2_INCLUDED
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
// Purely doxygen documentation
|
||||||
|
|
||||||
|
|
||||||
|
// What follows is the docs for the examples.
|
||||||
|
// I'd like the docs to be just before the
|
||||||
|
// actual examples in xmltest.cpp, but I
|
||||||
|
// can't seem to get doxygen to do that. It
|
||||||
|
// would be a wonderful patch if anyone figures
|
||||||
|
// it out.
|
||||||
|
|
||||||
|
/** @page Example-1 Load an XML File
|
||||||
|
* @dontinclude ./xmltest.cpp
|
||||||
|
* Basic XML file loading.
|
||||||
|
* The basic syntax to load an XML file from
|
||||||
|
* disk and check for an error. (ErrorID()
|
||||||
|
* will return 0 for no error.)
|
||||||
|
* @skip example_1()
|
||||||
|
* @until }
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @page Example-2 Parse an XML from char buffer
|
||||||
|
* @dontinclude ./xmltest.cpp
|
||||||
|
* Basic XML string parsing.
|
||||||
|
* The basic syntax to parse an XML for
|
||||||
|
* a char* and check for an error. (ErrorID()
|
||||||
|
* will return 0 for no error.)
|
||||||
|
* @skip example_2()
|
||||||
|
* @until }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @page Example-3 Get information out of XML
|
||||||
|
@dontinclude ./xmltest.cpp
|
||||||
|
In this example, we navigate a simple XML
|
||||||
|
file, and read some interesting text. Note
|
||||||
|
that this is examlpe doesn't use error
|
||||||
|
checking; working code should check for null
|
||||||
|
pointers when walking an XML tree, or use
|
||||||
|
XMLHandle.
|
||||||
|
|
||||||
|
(The XML is an excerpt from "dream.xml").
|
||||||
|
|
||||||
|
@skip example_3
|
||||||
|
@until </PLAY>";
|
||||||
|
|
||||||
|
The structure of the XML file is:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>(declaration)</li>
|
||||||
|
<li>(dtd stuff)</li>
|
||||||
|
<li>Element "PLAY"</li>
|
||||||
|
<ul>
|
||||||
|
<li>Element "TITLE"</li>
|
||||||
|
<ul>
|
||||||
|
<li>Text "A Midsummer Night's Dream"</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
For this example, we want to print out the
|
||||||
|
title of the play. The text of the title (what
|
||||||
|
we want) is child of the "TITLE" element which
|
||||||
|
is a child of the "PLAY" element.
|
||||||
|
|
||||||
|
We want to skip the declaration and dtd, so the
|
||||||
|
method FirstChildElement() is a good choice. The
|
||||||
|
FirstChildElement() of the Document is the "PLAY"
|
||||||
|
Element, the FirstChildElement() of the "PLAY" Element
|
||||||
|
is the "TITLE" Element.
|
||||||
|
|
||||||
|
@until ( "TITLE" );
|
||||||
|
|
||||||
|
We can then use the convenience function GetText()
|
||||||
|
to get the title of the play.
|
||||||
|
|
||||||
|
@until title );
|
||||||
|
|
||||||
|
Text is just another Node in the XML DOM. And in
|
||||||
|
fact you should be a little cautious with it, as
|
||||||
|
text nodes can contain elements.
|
||||||
|
|
||||||
|
@verbatim
|
||||||
|
Consider: A Midsummer Night's <b>Dream</b>
|
||||||
|
@endverbatim
|
||||||
|
|
||||||
|
It is more correct to actually query the Text Node
|
||||||
|
if in doubt:
|
||||||
|
|
||||||
|
@until title );
|
||||||
|
|
||||||
|
Noting that here we use FirstChild() since we are
|
||||||
|
looking for XMLText, not an element, and ToText()
|
||||||
|
is a cast from a Node to a XMLText.
|
||||||
|
*/
|
Loading…
Reference in New Issue