This may be a dumb question but I have been struggling to load my xml content directly from a string rather than an xml file. I was able to compile and link the sample tinyxml code but I can't change it to accept an xml string and work with that rather than going the longer way to store the xml data in a file and then load it.
Any example of doing this is appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks, I have figured it out. I was missing the rest of the files from my project. After including all the needed cpp files, the problem is solved now.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This may be a dumb question but I have been struggling to load my xml content directly from a string rather than an xml file. I was able to compile and link the sample tinyxml code but I can't change it to accept an xml string and work with that rather than going the longer way to store the xml data in a file and then load it.
Any example of doing this is appreciated.
void demo1()
{
TiXmlDocument doc;
doc.Parse("<?xml version='1.0' ?>\n<message>Hello</message>");
printf("Message is [%s]\n", doc.FirstChildElement()->GetText());
}
produces:
Message is [Hello]
Press any key to continue
Thanks for the quick reply. Now I am having trouble linking my program. I am using Visual Studio 2003. Here are the errors:
error LNK2001: unresolved external symbol "protected: virtual class TiXmlNode * __thiscall TiXmlDocument::Clone(void)const " (?Clone@TiXmlDocument@@MBEPAVTiXmlNode@@XZ)
error LNK2001: unresolved external symbol "protected: virtual void __thiscall TiXmlDocument::FormattedStreamOut(class std::basic_ostream<char,struct std::char_traits<char> > *,int)const " (?FormattedStreamOut@TiXmlDocument@@MBEXPAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
error LNK2001: unresolved external symbol "protected: virtual void __thiscall TiXmlDocument::StreamIn(class std::basic_istream<char,struct std::char_traits<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?StreamIn@TiXmlDocument@@MAEXPAV?$basic_istream@DU?$char_traits@D@std@@@std@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z)
error LNK2001: unresolved external symbol "protected: virtual void __thiscall TiXmlDocument::StreamOut(class std::basic_ostream<char,struct std::char_traits<char> > *)const " (?StreamOut@TiXmlDocument@@MBEXPAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
error LNK2001: unresolved external symbol "public: virtual char const * __thiscall TiXmlDocument::Parse(char const *,class TiXmlParsingData *,enum TiXmlEncoding)" (?Parse@TiXmlDocument@@UAEPBDPBDPAVTiXmlParsingData@@W4TiXmlEncoding@@@Z)
error LNK2001: unresolved external symbol "public: virtual void __thiscall TiXmlDocument::Print(struct _iobuf *,int)const " (?Print@TiXmlDocument@@UBEXPAU_iobuf@@H@Z)
error LNK2019: unresolved external symbol "public: __thiscall TiXmlDocument::TiXmlDocument(void)" (??0TiXmlDocument@@QAE@XZ) referenced in function "public: void __thiscall XmlParser::dump_to_stdout(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?dump_to_stdout@XmlParser@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
error LNK2019: unresolved external symbol "public: virtual __thiscall TiXmlNode::~TiXmlNode(void)" (??1TiXmlNode@@UAE@XZ) referenced in function "public: virtual __thiscall TiXmlDocument::~TiXmlDocument(void)" (??1TiXmlDocument@@UAE@XZ)
thanks, I have figured it out. I was missing the rest of the files from my project. After including all the needed cpp files, the problem is solved now.