![]() |
|
#1
|
|||
|
|||
Displaying node attributes in an XML tree displayI have successfully managed to display some XML code in a tree, but currently only the node names are given. I would also like to display any attributes (i.e. everything inside the node, not just the name) but can't for the life of me find out how! Please help - I appreciate your efforts very much!
CPP / C++ / C Code:
I know the 'hChild = m_Tree -> InsertItem(pParent -> nodeName, hParent, TVI_LAST);' line is where the text for the tree comes from but I don't know what to use in place of nodeName. I hope this all makes sense. Thanks again! Last edited by LuciWiz : 07-Feb-2005 at 05:19.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|||
|
#2
|
|||
|
|||
|
It's alright - I've just managed to sort it. This needs to be done for each node if anyone has had the same problem:
-------------------------------------------------------------------------- // Create object containing attributes IXMLDOMNamedNodeMap* attr; HRESULT hr; hr = pParent->get_attributes(&attr); _bstr_t node_properties; node_properties += pParent->nodeName; // Add each attribute in the node to a string if (attr != NULL) { for (int i = 0; i < attr->length; i++) { IXMLDOMNode* node; attr->get_item(i,&node); node_properties += (" " + *&node->nodeName + "=\"" + *&node->text + "\""); } } // Add string into tree hChild = m_Tree -> InsertItem(node_properties, hParent, TVI_LAST); -------------------------------------------------------------------------- |
|
#3
|
||||
|
||||
|
just an addition reference...
here is an excellent wrappper for the xml document element, i found it some where in the net before, don't remember where though... CPP / C++ / C Code:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ineed some help with thos code - Linear Linked List | sosy2001 | C Programming Language | 6 | 11-Nov-2004 11:23 |
| Linked List | Kareem1984 | C Programming Language | 5 | 07-Oct-2004 18:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The