// DOMWriter.cpp : Defines the entry point for the application. // #pragma warning(disable: 4786 4250 4503) #include #include #include template void doChildren(std::basic_ostream& stream, DOM::Node& node) { DOM::Node child = node.getFirstChild(); while(child != 0) { stream << child; child = child.getNextSibling(); } // while } // doChildren template std::basic_ostream& operator<<(std::basic_ostream& stream, DOM::Node& node) { switch(node.getNodeType()) { case DOM::Node::DOCUMENT_NODE: doChildren(stream, node); break; case DOM::Node::ELEMENT_NODE: stream << "<" << node.getNodeName() << ">"; doChildren(stream, node); stream << ""; break; case DOM::Node::TEXT_NODE: stream << node.getNodeValue(); break; } // switch return stream; } // operator<< //////////////////////////////////////////////// int main(int argc, char* argv[]) { if(argc < 2) { std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl; return 0; } // if(argc < 2) SAX2DOM::Parser domParser; for(int i = 1; i < argc; ++i) { std::string file(argv[i]); SAX::InputSource is; is.setSystemId(file); if(file != "-") domParser.parse(is); else { is.setSystemId("stdin"); is.setByteStream(std::cin); domParser.parse(is); } // if(file != "-") DOM::Document doc = domParser.getDocument(); std::cout << doc; } // for ... return 0; } // main // end of file