32 #include "FGXMLParse.h"
33 #include "input_output/string_utilities.h"
43 void FGXMLParse::reset(
void)
45 current_element = document =
nullptr;
46 working_string.erase();
51 void FGXMLParse::dumpDataLines(
void)
53 if (!working_string.empty()) {
54 for (
auto s: split(working_string,
'\n'))
55 current_element->AddData(s);
57 working_string.erase();
62 void FGXMLParse::startElement (
const char * name,
const XMLAttributes &atts)
65 document =
new Element(name);
66 current_element = document;
70 Element* temp_element =
new Element(name);
72 temp_element->SetParent(current_element);
73 current_element->AddChildElement(temp_element);
75 current_element = temp_element;
78 if (!current_element) {
79 cerr <<
"In file " << getPath() <<
": line " << getLine() << endl
80 <<
"No current element read (running out of memory?)" << endl;
84 current_element->SetLineNumber(getLine());
85 current_element->SetFileName(getPath());
87 for (
int i=0; i<atts.size();i++) {
88 current_element->AddAttribute(atts.getName(i), atts.getValue(i));
94 void FGXMLParse::endElement (
const char * name)
97 current_element = current_element->GetParent();
102 void FGXMLParse::data (
const char * s,
int length)
104 working_string += string(s, length);
109 void FGXMLParse::warning (
const char * message,
int line,
int column)
111 cerr <<
"Warning: " << message <<
" line: " << line <<
" column: " << column