我正在尝试解析来自另一个XML格式的系统的响应。我决定使用RapidXML作为解析器。一切正常,直到系统报告“ faultResponse”消息。尝试处理“ faultResponse”消息时,出现解析错误
我确保捕获了异常代码,并说这是一个解析错误。 “预期<”。我正在查看发送系统,他们记录了发送的内容,因此我知道它不缺少<。我尝试xmllint验证它是一个好文件,而xmllint说它很好。
从远程系统发送的实际XML
<FaultResponse sequenceNumber="10004993">
<Exception type="System.Exception">
<message>Distribution Exception: </message>
<detail>System.Exception: Distribution Exception: ---> System.Exception: Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
--- End of inner exception stack trace ---</detail>
<Exception type="System.Exception">
<message>Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password</message>
<detail>System.Exception: Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password</detail>
</Exception>
</Exception>
</FaultResponse>
// get message from system and store in variable target
rapidxml::xml_document<> doc;
try
{
doc.parse<0>(target);
}
catch (const std::runtime_error& e)
{
std::cerr << "Runtime error was: " << e.what() << std::endl;
}
catch (const rapidxml::parse_error& e)
{
std::cerr << "Parse error was: " << e.what() << std::endl;
cout << "Trying to parse: " << target << " of size " << strlen(target) << endl;
}
catch (const std::exception& e)
{
std::cerr << "Error was: " << e.what() << std::endl;
}
catch (...)
{
std::cerr << "An unknown error occurred." << std::endl;
}
我希望使doc变量具有xml文档的内容,并开始逐步处理它,但是我遇到了解析错误。
答案 0 :(得分:0)
我做了更多的测试,看来XML文件是有效的并且能够被解析。我创建了一个单独的程序对其进行测试,并且Rapidxml正常工作。看起来有些东西正在破坏目标变量。