Error in TXMLEngine::ParseFile: Unexpected end of xml

Hi @yus ,
Hi root experts ,
I have a problem if i use MVAClassificationApplication.C code to fit my histograms and find the suitable cut for both of sinal and background.But i find error during run this code

*///////////////////////////////////////////////

rocessing TMVAClassificationApplication.C(“BDT”)…

==> Start TMVAClassificationApplication
Error in TXMLEngine::ParseFile: Unexpected end of xml file
: Trying to read non-existing attribute ‘Method’ from xml node ’
***> abort program execution
terminate called after throwing an instance of ‘std::runtime_error’
what(): FATAL error
*//////////////////////////////////////////////////////////////////
To clarify my problem accurately. I think in this section of the code

 // Book method(s)

for (std::mapstd::string,int::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = TString(it->first) + TString(" method");
TString weightfile = dir + prefix + TString(“_”) + TString(it->first) + TString(“.weights.xml”);
reader->BookMVA( methodName, weightfile );
}

*/////////////////////////////////////

thanks ,
Ahmed

TMVAClassificationApplication.C (23.0 KB)
bb.root (45.5 KB)
h_bb.root (45.5 KB)
h90BP1_bb.root (55.9 KB)
h90BP2_bb.root (55.3 KB)
h95BP1_bb.root (55.4 KB)

h95BP3_bb.root (56.1 KB)
h96BP1_bb.root (21.7 KB)
h96BP2_bb.root (56.2 KB)
h96BP3_bb.root (56.9 KB)
h96BP6_bb.root (54.5 KB)

Hi @Ahmed_Sayed,

From the given log, all I can tell is that you have some problem with an xml file. It would be great if you can provide a minimal example that I can replicate.

Thanks,
Dev

Hi @devajith ,
I searched for an example look like the located problem out of code hopping to help
Us in the problem

*†****†***†*********

#include <iostream>
#include <string>
#include <exception>

#include <TXMLEngine.h>

using namespace std;

void f()
{
    TXMLEngine xml;
    XMLDocPointer_t xmldoc = xml.ParseFile("MVACalib_electron_Et20-40_eta1.52-1.55_Eaccordion_BDT.weights.xml");
    XMLNodePointer_t mainnode = xml.DocGetRootElement(xmldoc);
    XMLNodePointer_t user_info_node = xml.GetChild(mainnode);
    int i=0;
    while (string(xml.GetNodeName(user_info_node)) != "xyz")
    {
	user_info_node = xml.GetNext(user_info_node);
	cout << xml.GetNodeName(user_info_node) << endl;
	if ((i++) > 30) break;
    }

*†****************

thanks,
Ahmed

Hi Ahmed,

Can you provide content of XML file?

Regards,
Sergey

Thanks all root expert especially @devajith
For a great effort with me. The problem is solved

1 Like

Thanks all root experts. The problem is solved

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.