Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPPropExchangeXMLNode how to traverse all nodes?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropExchangeXMLNode how to traverse all nodes?

 Post Reply Post Reply
Author
Message
dmunoz View Drop Down
Newbie
Newbie


Joined: 18 June 2006
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmunoz Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropExchangeXMLNode how to traverse all nodes?
    Posted: 18 June 2006 at 8:53am
Hi,

I'm evaluating Xtreme TookitPro and so far I'm quite happy with what I've try. I'm baffled by something though.

I need to read/write some dynamic content in XML, and what hoping to use for that CXTPPropExchangeXMLNode. But I can't figure how to traverse all nodes after a LoadFromFile !

If I know the node names, I understand I can do it with CXTPPropExchangeSection or GetEnumerator, but how if I don't know the names, and I need to traverse all the XML tree structure node after node and read their content ?

Couldn't find an example in the Sample files. Anyone care to point me in the right direction ?

Thanks for any help.

Back to Top
WindFlashing View Drop Down
Groupie
Groupie


Joined: 21 March 2006
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindFlashing Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2006 at 10:05pm

There are two ways,

1.Use CXTPPropExchangeEnumeratorPtr:

 CXTPPropExchangeEnumeratorPtr pEnumerator(m_pSection->GetEnumerator(_T("*")));
 pos = pEnumeratorMenu->GetPosition();
 while (pos)
 {
  CXTPPropExchangeXMLNode* pNode = pEnumerator->GetNext(pos));
  // ...
 }
 
2.Use m_xmlSectionNode in CXTPPropExchangeXMLNode,
 
UINT CPropExchangeXMLNodeEx::GetNodesCount(LPCTSTR lpszSection)
{
 if (m_xmlSectionNode == NULL)
 {
  return 0;
 }
 HRESULT hr;
 UINT length;
 IXMLDOMNodePtr xmlNodePtr;
 IXMLDOMNodeListPtr xmlNodeListPtr;
 hr = m_xmlSectionNode->selectNodes(_bstr_t(lpszSection ? lpszSection : _T("*")), (XTPXML::IXMLDOMNodeList**)&xmlNodeListPtr);
 //...
  }
Back to Top
dmunoz View Drop Down
Newbie
Newbie


Joined: 18 June 2006
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmunoz Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2006 at 7:38am
Thanks for the help, now I understand. I was able to traverse the nodes with CXTPPropExchangeEnumeratorPtr, and retrieve each node name with xmlSectionNode::get_nodeName.

I find strange though that there is no simple interface within the CPropExchangeXMLNode class, and that one need first to derive the class to be able to access m_xmlSectionNode  protected member, then to be forced to call the COM interface to get some details about the node, like its name. Some functions within CPropExchangeXMLNode class would have been useful. Or did I miss them ?

I see you have a CPropExchangeXMLNodeEx class, is that part of the XTreme Toolkit package ? Or is there something a little more elaborate planned in the Toolkit for working with XML files ?

Thanks again.
 
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2006 at 7:57am
Hi,
 
You don't need to access CXTPPropExchangeXMLNode members.
 
Check this sample: PropExchangeSam.zip
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
dmunoz View Drop Down
Newbie
Newbie


Joined: 18 June 2006
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmunoz Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2006 at 8:49am
Ah !
That is the sample I needed !

Now I understand better how to read the XML data.

Thanks Oleg.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.