|
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!
|
|
|
|
|
Hi.
I have this piece of XML:
<br />
<SessionsList><br />
<Session ID="2" FrameID="1"><br />
<MessageType>0x2B</MessageType><br />
< Params><br />
<BMRID>0x01</BMRID><br />
<SessionID>0x02</SessionID><br />
<FrameID>0x01</FrameID><br />
</Params> <br />
</Session><br />
</SessionsList><br />
My question is, How can I use the 'FindNodes()' to find me all 'Sessions' where ID=2 AND FrameID=1 ???
I tried:
node.FindNodes("//Session[@ID='2' FrameID='1']")
node.FindNodes("//Session[@ID='2' @FrameID='1']")
node.FindNodes("//Session[@ID='2' & FrameID='1']")
none of them works, but if I write
node.FindNodes("//Session[@ID='2']")
it doesn work, but I need it to find all nodes with 2 conditions and not 1.
Thanks.
Oren
-- modified at 2:54 Tuesday 23rd October, 2007
|
|
|
|
|
Hi, you should use: node.FindNodes("//Session[@ID='2' and @FrameID='1']")
Creative minds - create creative creations!
|
|
|
|
|
Hi All,
Thanks for this great article, I'd really like to be able to use this method to work with XML, but i'm having trouble compiling.
The example download compiles fine, but if I follow the steps:
- add XmlNodeWrapper.cpp file, then #include the header
I get compilation errors
Here are the first 3 errors:
error C2440: 'default argument' : cannot convert from 'const char [1]' to 'LPCTSTR' ..\XmlNodeWrapper.h (line)72
error C2548: 'CXmlDocumentWrapper::Save' : missing default parameter for parameter 1 ...\XmlNodeWrapper.h (line)72
error C2039: 'Getattributes' : is not a member of 'MSXML2::IXMLDOMNode' ...\XmlNodeWrapper.cpp (line)46
Any ideas where i'm going wrong? is there some other setting I've missed?
Thanks!
|
|
|
|
|
|
Uou must be using some different unicode settings...
Try playing with those.
Creative minds - create creative creations!
|
|
|
|
|
Dear,
I get success at creating the ProcessingInstruction as below:
IXMLDOMElementPtr spElementRoot = m_xmldoc->createElement("Root");
m_xmldoc->documentElement = spElementRoot;
xmldoc->insertBefore((IXMLDOMNode*)m_xmldoc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), _variant_t((LPDISPATCH)spElementRoot.GetInterfacePtr()));
But the problem is I don't know how to create this string (right below xml version = "1.0"):
Is it a ProcessingInstruction or a TextNode?
Please help!
|
|
|
|
|
Answered by myself:
Is it a ProcessingInstruction or a TextNode?
It is a comment, and to insert it right below the processing instruction call insertBefore like this:
xmldoc->insertBefore((IXMLDOMNode*)m_xmldoc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), _variant_t((LPDISPATCH)spElementRoot.GetInterfacePtr()));
xmldoc->insertBefore(m_xmldoc->createComment(__bstr_t("Generated by Alex Hazanov"), _variant_t((LPDISPATCH)spElementRoot.GetInterfacePtr()));
Thank you all!
|
|
|
|
|
MSXML2::IXMLDOMNode* CXmlNodeWrapper::FindNode(LPCTSTR searchString)
So many thanks but when I try to use FindNode method, I get fail.
For example, I had built this xml doc:
<code>
<Box ID="box_id2" Path="C:\">
<File FileName="artpdbg.log" />
<File FileName="GHOST.EXE" />
</Box>
</code>
But when I called root.FindNode("//Box[@ID='box_id2']") I got a NULL pointer.
Please help!
|
|
|
|
|
It must be my fault. I works now. Thanks
|
|
|
|
|
Dear Alex,
I have a trouble using your XML wrapper
I have to remove all the items contained in a section of xml files (both nodes and values). The RemoveNodes member allow to remove the nodes .... but .... how the remove all the values contained in a branch?
Thank You
Furno G.Luca
------------------------------------------------------------
Furno G.Luca
MicroSHADOW Research (uS)
Development dept.
Via Garibaldi, 25
19020 Ceparana (SP) - ITALY
Tel : +39(0187)940951
Fax: +39(199)449896
Mobile : 3337665111
e-mail: info@microshadow.com
web: http://www.microshadow.com
------------------------------------------------------------
|
|
|
|
|
Basically when you remove a node , you remove all the values and child nodes that it has... so I am not sure I understand your question... A small example would help.
Creative minds - create creative creations!
|
|
|
|