Click to See Complete Forum and Search --> : XML DOM problem with node


help_cplus
February 15th, 2005, 07:14 AM
Hi,
I have an XML document..

<register name="RID" length="32" address="0x8" resetval="000" access="rw">
<element name="RID" offset="1" length="7" access="rw">
<desc>Revision Identification Number. </desc>
<modified>true</modified>
<state text="A0 stepping" value="" />
<state text="A1 stepping" value="" />
<state text="A2 stepping" value="" />
<state text="B0 stepping" value="" />
</element>
</register>

I need to access the "state" programically using MSXML..

I could reach till element and their attributes..
But I am unable to get to the "state" and text and value associated with it..
Anybody had any idea..

i have used the code below..


IXMLDOMNode *pNode;
IXMLDOMNode *pNode_child;
IXMLDOMNodeList *childList;
long atlen, pos,
hr = pNode->get_childNodes(&childList); // gives the list of nodes under register
hr = childList->get_length(&atlen_child);

for(pos =0; pos<atlen_child;pos++)
{
hr = childList ->nextNode(&pNode_child);
myFunc(pNode_child);
}

void myFunc(IXMLDOMNode *pNode_child)
{
IXMLDOMNamedNodeMap *AtMap;
pNode_child->get_attributes(&AtMap);
AtMap->get_length(&atlen);
for(pos = 0; pos<atlen;pos++)
{
// now we have the attributes of the element node..
// now what shud be done for getting the 'state '
}
}


Thank you

Ajay Vijay
February 15th, 2005, 08:14 AM
You have not created the instance of 'pNode' and directly using it.

- Ajay.

help_cplus
February 15th, 2005, 09:03 AM
I dont understand..
could you explain?

Krzemo
February 16th, 2005, 05:36 AM
Why not "pNode_child->getAttribute("text")" ?



I dont understand..
could you explain?
Ajay Vijay coplain about missing things like that:
".CreateDispatch("MSXML2.DOMDocument")", "loadXML(" ... etc.

U delcared "IXMLDOMNode *pNode;" but there is no assigment to that pointer.

Best regards,
Krzemo.