|
Thank you , it works fine , but a little trouble about memory leak .
While I finished using it , I called detach or release methods to free memory , but it was not effective.
So would you please help me about this issue ?
Expecting your reply , thank you!
|
|
|
|
|
Any ideas about how to release the memory after using it? I tried many ways, but could not figure out. Please let me know if anyone has an idea for it. Thanks.
|
|
|
|
|
I encountered same memory leak issue. anyone can provide solution for me? thanks.
|
|
|
|
|
I also stuck in this issue. Anybody was fixed it? Please help me. Thanks!
|
|
|
|
|
I were fix this issue.
We using "IXMLDOMNodePtr" replace for "IXMLDOMNode*" accept these functions:
MSXML2::IXMLDOMNode* Interface();
MSXML2::IXMLDOMNode* Detach();
And we does not using Detach() when GetNode.
for examle:
MSXML2::IXMLDOMNode* CXmlNodeWrapper::GetNode(LPCTSTR nodeName)
--->>
MSXML2::IXMLDOMNodePtr CXmlNodeWrapper::GetNode(int nodeIndex)
return m_xmlnode->selectSingleNode(nodeName).Detach();
-->>
return m_xmlnode->selectSingleNode(nodeName);
|
|
|
|
|
Hi,
Nice class but i am having problem using it to remove the node. I call RemoveNode and then it does not compile. Here is what i have tried.
xmlNode = m_xmlDownloadList.AsNode();
CXmlNodeWrapper resultNode(xmlNode.FindNode("//File[@Path='1'"));
if ( resultNode.IsValid() )
{
xmlNode.RemoveNode(resultNode);
}
It gives a compile time error:
c:\program files\microsoft visual studio\vc98\include\comip.h(74) : error C2451: conditional expression of type 'const class CXmlNodeWrapper' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Documents and Settings\nak\My Documents\Downloads\xmlview\XMLViewDlg.cpp(285) : see reference to function template instantiation '__thiscall _com_ptr_t<class _com_IIID<struct MSXML2::IXMLDOMNode,&struct __s_GUID _GUID_2933bf80_7b36_11d2_b
20e_00c04f983e60> >::_com_ptr_t<class _com_IIID<struct MSXML2::IXMLDOMNode,&struct __s_GUID _GUID_2933bf80_7b36_11d2_b20e_00c04f983e60> >(const class CXmlNodeWrapper &)' being compiled
I also tried this
xmlNode = m_xmlDownloadList.AsNode();
CXmlNodeWrapper resultNode(xmlNode.FindNode("//File[@Path='1'"));
if ( resultNode.IsValid() )
{
xmlNode.RemoveNode(&resultNode); // passing reference
}
I get
c:\program files\microsoft visual studio\vc98\include\comip.h(690) : error C2039: 'QueryInterface' : is not a member of 'CXmlNodeWrapper'
c:\documents and settings\nak\my documents\downloads\xmlview\xmlnodewrapper.h(16) : see declaration of 'CXmlNodeWrapper'
c:\program files\microsoft visual studio\vc98\include\comip.h(75) : see reference to function template instantiation 'long __thiscall _com_ptr_t<class _com_IIID<struct MSXML2::IXMLDOMNode,&struct __s_GUID _GUID_2933bf80_7b36_11d2_b20e_00c04f
983e60> >::_QueryInterface(class CXmlNodeWrapper *const & )' being compiled
I am really confused what can be the issue. I can see the reasons for the errors but then how can i remove a node using your class. Please help, i need to work out something urgent. No complex code i have written, only inserted 5 nodes and they were inserted and then trying to remove a node. Thanks in Advance
|
|
|
|
|
Hi,
No help provided on this article anymore? I am having issues in find node too. It will be great if you can share a helping hand on how to use it because sample you have given is very basic and does not really use all of the functions.
Thanks
|
|
|
|
|
Hi decentsmile, sorry to keep ypu waiting I wasn't around for a while...
How ever from your code it is impossible to figure out what is wrong...
Please send me a sample project (including the article's files) to tempo001 at rdvsystems dot com
And I'll try to figure out what is wrong.
Creative minds - create creative creations!
|
|
|
|
|
Hi..any update on this issue? I am oso working at this removenode with similar problem...
|
|
|
|
|
When I use InsertNode it adds the attribute "xmlns" to the node.
ie the code
CSULXmlNodeWrapper nodRoot = m_xmlDoc.AsNode();
CSULXmlNodeWrapper nodSection = nodRoot.InsertNode(m_DocumentNode.NumNodes(), "Welcome");
CSULXmlNodeWrapper nodProperty = nodSection.InsertNode(0, "Message");
nodProperty.SetText("0");
adds
<Welcome xmlns=""><Message>0</Message></Welcome>
to the xml file. Whereas I want
<Welcome><Message>0</Message></Welcome>
How can I avoid this?
TIA
|
|
|
|
|
Hai Alex,
I am new student in learn XML language...
Could you help me...?
I find my difficulty when I want print data in xml language
For example I have 10 records then I want print
Test1, Test2, Test 3, Test4, then print Sample1, and the looping
Print again for Test1, Test2, Test3, Test4, and Then Print Sample2.
Thanks for the help.
|
|
|
|
|
Dear Alex:
Thanks for your great job.
I also find your class had something is needed to adjust for Unicode project.
I don't know how to mail you straight by codeproject, and your blog also can't link with. So, if you would like to see what I been changed. Please mail me, I would like to mail you that my added changes.
Sincerely,
|
|
|
|
|
I have this xml.
<x:recording xmlns:x="http://www.dddd.com/xmlns/aaa" x:ref="ddaa">
<x:rtptype x:ctr="19">0
<x:attrib x:ctr="17">sendrecv
<x:attrib x:ctr="15">fmtp:103 0-15
I want to insert this node.
<x:starttime x:ctr="1" xmlns:x="#unknown">2008-12-04
node.InsertNode(node.NumNodes(), "//x:starttime");
but it doesn work. only runtime error.
help me!
|
|
|
|
|
Use:
node.InsertNode(node.NumNodes(), "x:starttime");
i.e. : remove the slashes
Creative minds - create creative creations!
|
|
|
|
|
thanks for your answer!
but .. i still have a problem
node.InsertNode(node.NumNodes(), "x:starttime"); // <-- runtime error!
node.InsertNode(node.NumNodes(), "xstarttime"); // <- insert ok!
how can i solve this problem?
|
|
|
|
|
I have this xml.
<?xml version="1.0" encoding="UTF-8" ?>
<x:recording xmlns:x="http://www.dddd.com/xmlns/aaa" x:ref="ddaa">
<x:rtptype x:ctr="19">0</x:rtptype>
<x:Attrib x:ctr="17">sendrecv</x:Attrib>
<x:Attrib x:ctr="15">fmtp:103 0-15</x:Attrib>
</x:recording>
I want to insert this node.
<x:starttime x:ctr="1">2008-12-04</x:starttime>
node.InsertNode(node.NumNodes(), "//x:starttime");
but it doesn work. only runtime error.
help me!
|
|
|
|
|
How do I update an attribute of a node?
node.SetValue works but it places the node at then end of the file and this upsets the loop though the nodes when you try and reload the XML file
|
|
|
|
|
You would have to eleborate on the subject since I didn't get what the issue is, since SetValue usualy works for me without any problem... This just sets the attribute without changing the node or it's position...
Creative minds - create creative creations!
|
|
|
|
|
Hi Alex yes it is strange as I was using SetValue and it was changing the values fine but it would place the updated value at the end of the main tag so when the application re read the XML it would not loop though the nodes correctly as 0 or 1,2,3 and so on were no longer in order and the loop failed but I guess there is a work around for this.
|
|
|
|
|
Great article!
I have only a small suggestion (which I'll make in the version that I'll use):
Why not having GetValue functions for int, short, double etc, like the SetValue ones?
Otherwise a top notch work. I voted 6 only because there is no higher value .
Best regards,
X3m
|
|
|
|
|
Thanks alot, I appreciate the input.
Your suggestion among other usefull additions are awaiting me, finding some free time to update the article...
Alas... you should understand what it means... hopefully in near future.
Creative minds - create creative creations!
|
|
|
|
|
I don't see any sort of license attached to the article or downloaded source. Does this mean that you have released the code as Public Domain?
I need to know the "official" license state so I can determine if this code could be used in my product. It would sure save me a lot of headache if I could, but need to know that any code I use is not infringing.
Thank you.
|
|
|
|
|
Appropriate license was applied... Bug fixed
Thing is, that the article was published before CP imlemented thier licensing policies so it was not updated.
Thanks for bringing this to my attention.
Creative minds - create creative creations!
|
|
|
|
|
Hi.
I need to create this piece of code,
<br />
<SessionsList><br />
<Session ID="2" FrameID="1"><br />
</Session><br />
</SessionsList><br />
How can I do that??
I tried:
<br />
CXmlNodeWrapper Session(pNextSessionNode=pXmlNodeWrapper.InsertNode(0, "Session"));<br />
sprintf(szXmlStr, "ID=%c0x%02X%c FrameID=%c0x%02X%c", '"', pSessionData->GetSessionID(), '"', '"', pSessionData->GetUniqueID(), '"');<br />
Session.SetText(szXmlStr);<br />
it doesn't work...any ideas ??
Thanks.
Oren.
|
|
|
|
|
node.SetValue("ID", szID);
node.SetValue("FrameID", szFrameID);
Creative minds - create creative creations!
|
|
|
|