Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with the GetAttributes command

Status
Not open for further replies.

SteveyC

Programmer
Nov 25, 2003
5
GB
Morning All.

I have loaded my XML doucment and am trying to extract one of the attributes from an XML tag. The XML Tag I am working with looks like:

<SDComponent Name=&quot;Average&quot; ComponentOid=&quot;_040g02g0g0001ko7047074srq0200&quot;>

I tried using the lines below to no avail. It just returns back nonsense.
CString componentDetails;
componentDetails = pComponentNode->Getattributes();


Ideally I want to be able to call a function, pass in the attribute name and get the value of that attribute back. Can anybody point me in the right direction?

Thanks
 
Hi.

Never mind, found a resident C++ guy (much to his dismay) and he has helped me work out a solution. For those that are interested.

CComponent::processComponent(IXMLDOMElementPtr pComponentNode)
{
IXMLDOMNodePtr myAttribute;
unsigned int numAttributes;

// Extract the attribute information for this component
numAttributes = pComponentNode->childNodes->length;
m_componentName = pComponentNode->getAttribute((LPCTSTR)xml_name_s).bstrVal;
m_componentID = pComponentNode->getAttribute((LPCTSTR)xml_component_id_s).bstrVal;

AfxMessageBox(pComponentNode->xml);
}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top