问题
The xml can only be referred to in the code as an external link for eg. "www.etc.com". I want to be able to extract certain words from the page source of certain websites, but first i need to dump the source content into a string or CString. Thanks for any help
回答1:
I think what you are asking is how to fetch data from the internet. I found this thread and some source code regarding this.
回答2:
You can use a DOM or SAX parser to retrieve each element.
If you want the entire xml file content in memory, then here is the sample code to make it
ifstream fin("books.xml");
if ( fin.fail())
return 1;
fin.seekg(0, ios::end);
size_t length = fin.tellg();
fin.seekg(0, ios::beg);
char* buffer = new char[length+1];
fin.read(buffer, length);
buffer[length] = '\0';
fin.close();
来源:https://stackoverflow.com/questions/11734371/how-to-store-entire-source-of-xml-file-as-a-string-in-c