|
Needs to be called for each thread, not each object. Also, make sure that each CoInitialize is balanced with a CoUninitialize.
|
|
|
|
|
m_xmldoc always = NULL,because you put the function----CoInitialize(NULL) a wrong space.
you use the class in dialog framework.you want use the class in xxxDlg,you must put CoInitialize(NULL) before create DLG.
for example,
BOOL CMyApp::InitInstance()
{
CoInitialize(NULL); ---------Right method
CMyDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
}
BOOL CMyApp::InitInstance()
{
CMyDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
CoInitialize(NULL); ---------error method
}
|
|
|
|
|
Hi Alex,
I tried to use your function into a simple dialog base program.
no problem to compile but after loading the xml file, nothing is displayed into the treeview. I tried to reproduce your demo program but when I check the value of the variable m_xmlDoc, the m_xmldoc is still to 0x00000000.
Any idea to solve my issue?
1) new project (dialog based)
2) #include "XmlNodeWrapper.h"
3) added lines
CXmlDocumentWrapper doc;
doc.LoadXML("<root><someobject>");
4) compile OK
5) execution using debug mode: doc.m_xmldoc = 0x00000000.
When I execute the sample code (XMLView), m_xmldoc is different from 0x00.
Any Idea?
Thanks for your help.
Best regards,
Jmi
-- modified at 3:05 Tuesday 10th April, 2007
|
|
|
|
|
Have you forgot to call :
CoInitialize(NULL);
???
Creative minds - create creative creations!
|
|
|
|
|
You're right, I forgot to call CoInitialize(NULL);
Thanks for you support. It's working fine.
|
|
|
|
|
Great Class
support the cyrillic character set (DOS codepage 866)?? thanks
|
|
|
|
|
Fantastic work!!!!
Thanks a lot!
Pity its stuck with Microsoft.
Does anybody know one like this for xerces??
|
|
|
|
|
for( int i=0; i < node.NumAttributes(); i++ )
{
CString name = node.GetAttribname(i);
CString value = node.GetAttribValue(i);
// Edit New Value
value = ...
// Edit
node.SetValue( name, value )
}
when I use this code.
It missed " node.GetAttribname(i); ".
It returns wrong value!!( It returns next Attribute Name & Value )
Maybe SetValue Function moves Attribute Pointer.
How can I get correct Attrib?
Good Cording
|
|
|
|
|
hi, thanks for that great work, but I want to load the xml file from a url, I tried the way which explained in some message but it didnt work,
I tried this way,
doc.Load("http://www.w3schools.com/xml/note.xml");
it didn't work, can you help me?
|
|
|
|
|
i found a way to load the xml from a url, thanks for that work.
|
|
|
|
|
Hi!
I've got a problem. I have a program which uses the XMLNodeWrapper. In my program I load a XML-File in a Tree. Then I can edit my entries. In the next step I want to store my changes to a new XML-File. But how do I get the changes? How can iterate my tree to get all entries?
Thanks a lot ...
Merlin
|
|
|
|
|
Which tree are you using? Is it a CTreeView? Or you custom control , or anything else?
If you want someone to help you you should be much more specific...
Also I did not quite understand the nature of your problem: do you have a problem to read the data from the tree , or to store the new data in an existing XML structure?
Creative minds - create creative creations!
|
|
|
|
|
Thanks for your answer an sorry for beeing not specific enough. I'm a beginner an I do my first steps in programming C++.
I'm using a CTreeCtrl. I can parse my xml file and then I can show it in my CTreeCtrl. I'm also able to edit my entries. For that I'm using the CanEditLabel. After editing my entries I want to save the whole tree again in a xml-file with all the changes. But how do I get all nodes and data from the tree? This is my problem.
I hope I explained it exactly (with my bad english)
Thanks ...
Merlin
|
|
|
|
|
Hi,
I want to use a XML file by specifying its network path.
How can i use it in the m_xml.Load(filename) function
Plz help me out.
Roy
|
|
|
|
|
Load("\\ServerName\ShareName\file.xml");
or if it is a URL :
Load("http://www.someserver.com/files/file.xml");
Creative minds - create creative creations!
|
|
|
|
|
Hi,
I want to use a XML file from specifying its network path.
How can i use it in the m_xml.Load(filename) function
Plz help me out.
Roy
|
|
|
|
|
In CXmlDocumentWrapper::Load(LPCTSTR path), I see that you use _variant_t v(path) and pass v to the m_xmldoc->load(v)
But in CXmlDocumentWrapper::LoadXML(LPCTSTR xml), you call m_xmldoc->loadXML(xml) directly.
Could this cause a memory leak?
|
|
|
|
|
Header:
CXmlDocumentWrapper m_xmlDoc ;
cpp:
CString CMainFrame::TestMem()
{
CString cs = _T("<confirmSession> </confirmSession>");
m_xmlDoc.LoadXML(cs);
CXmlNodeWrapper node(m_xmlDoc.AsNode());
node.SetValue(_T("transmissionTime") , _T("protocolVersion") );
CXmlNodeWrapper Node1 ( node .InsertNode(0,_T("protocolVersion") ) );
Node1.SetValue(_T("major") ,_T("1") );
Node1.SetValue(_T("minor") ,_T("0") );
CXmlNodeWrapper Node2 ( node .InsertNode(1,_T("server") ));
Node2.SetValue(_T("type") ,_T("DLS4000") );
Node2.SetValue(_T("test1") ,_T("test1") );
Node2.SetValue(_T("clientInstanceId") ,_T("ATS DLS4000") );
m_xmlDoc.LoadXML(node.GetXML());
return m_xmlDoc.GetXML();
}
This function increases the used Memory of the Program ( NO Memory Leak )
Where is my mistake ????
2. ND PRoblem: HANDELS
CString CMainFrame::TestMem()
{
CXmlDocumentWrapper* pxmlDoc = new CXmlDocumentWrapper;
CString cs = _T("<confirmSession> </confirmSession>");
pxmlDoc->LoadXML(cs);
CXmlNodeWrapper node(pxmlDoc->AsNode());
node.SetValue(_T("transmissionTime") , _T("protocolVersion") );
CXmlNodeWrapper Node1 ( node .InsertNode(0,_T("protocolVersion")) );
Node1.SetValue(_T("major") ,_T("1") );
Node1.SetValue(_T("minor") ,_T("0") );
CXmlNodeWrapper Node2 ( node .InsertNode(1,_T("server") ) );
Node2.SetValue(_T("type") ,_T("DLS4000") );
Node2.SetValue(_T("test1") ,_T("test1") );
pxmlDoc->LoadXML(node.GetXML());
CString csRet = pxmlDoc->GetXML();
delete pxmlDoc;
pxmlDoc = NULL;
return csRet;
}
No Memory Advantage, but here are unused Handels for every Funcion Call !!
|
|
|
|
|
Hello Folks,
has somebody an Idea, why are there so huge Memory Problems ?
|
|
|
|
|
|
Hello maury_73,
you had the same Problem, Do you have now the Solution ?
Greetings, Markus
|
|
|
|
|
Sorry... I have the same problem
|
|
|
|
|
Is there a way to remove an attribute from the node?
|
|
|
|
|
|
I have one question about FindNode member of CXmlNodeWrapper class.
I find a query with XPath syntax but the answers are always empty ("" ).
I don't use xsl file and the xml file sample contents is:
<images>
<rect name="__rPageSence">
Norm=( 711, 575, 794, 594 )
<rect name="__rPageSence">
Norm=( 711, 575, 794, 594 )
High=( 935, 743, 1018, 762 )
<rect name="__rPageSence">
Norm=( 711, 575, 794, 594 )
High=( 935, 743, 1018, 762 )
Why the result seems to be wrong.
Thanks.
|
|
|
|