-2
我试图解析一个.html文件定位到特定的标签,然后从位置开始我写达到文件:从的std :: fstream的不写入到.html文件
std::fstream file;
file.open(".\\img\\file.html", std::fstream::in || std::fstream::out);
if (file.is_open())
{
char s[1024];
bool f = false;
while(f != true)
{
file.getline(s,1024);
if (strstr(s,"<table>") != NULL)
f = true;
}
file << "Something";
}
else
printf("Error opening file.html\n");
调试我可以确认我找到想要的标签,但没有写入文件,我做错了什么?
使用['libxml ++']让生活变得更轻松(http://libxmlplusplus.sourceforge.net/docs/manual/html/) – P0W
感谢您的提示,但我的问题不在于解析。我的问题是我无法写入.html文件。 – user2837795
你不能只是去一个XML文件的某个部分,插入一个元素,期待剩下的内容魔术般地转移到使用基本流io创建空间。您需要为此使用XML工具包。 [看到这个问题关于如何为您的需要选择正确的](http://stackoverflow.com/questions/9387610/what-xml-parser-should-i-use-in-c/9387612#9387612)。 – WhozCraig