0

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 ?

Flaviu_
  • 1,285
  • 17
  • 33
  • Where did you get RapidXML from? The official manual [does not mention](https://rapidxml.sourceforge.net/manual.html) a `Validate` method – Botje Jun 28 '23 at 12:36
  • I got it from here: https://github.com/dwd/rapidxml – Flaviu_ Jun 28 '23 at 13:05
  • That is a fork, not the original. That is important information to include in your question. – Botje Jun 28 '23 at 13:40
  • I think all github repositories are forked, right ? https://github.com/search?q=rapidxml&type=repositories – Flaviu_ Jun 28 '23 at 15:11
  • No. discord/rapidxml is a pristine copy of the 1.13 codebase, for example – Botje Jun 28 '23 at 19:03

1 Answers1

0

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();
Flaviu_
  • 1,285
  • 17
  • 33