I have the following test xml:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:ht='https://google.com' version='2.0'>
<channel>
<atom:link href='https://google.com' rel='self' type='application/rss+xml'/>
<item>
<title>VC++ / MFC</title>
<ht:valaue>440</ht:valaue>
<description></description>
<link>https://google.com</link>
<Date>Tue, 27 Jun 2023 03:00:00 +0300</Date>
<ht:item>
<ht:title>Questions tagged mfc</ht:title>
<ht:url>https://stackoverflow.com/tags/mfc/</ht:url>
<ht:source>Akama</ht:source>
</ht:item>
</item>
</channel>
</rss>
And I have tried to validate it with (simplified):
rapidxml::xml_document<> doc;
CStdioFile file;
if (! file.Open(_T("C:\\Home\\Temp\\new.xml"), CFile::modeRead | CFile::typeText))
throw std::runtime_error("Error: Cannot open xml file");
CString sText, sLine;
while (file.ReadString(sLine))
sText.Append(sLine + _T("\n"));
doc.parse<0>(CT2A(sText));
doc.validate();
The issue is I always got: Element XMLNS unbound
. How can I overcome this issue ? Rapidxml
library cannot read this kind of xml ?
If I read the xml
file using std::ifstream
the issue dissapear.
Or, another option is to use rapidxml
tool:
rapidxml::xml_document<> doc;
rapidxml::file<> file("C:\\Home\\Temp\\rss.xml");
doc.parse<0>(file.data());
doc.validate();