Hi,
        the getInterface method call seems to throw a not supported
exception at the moment. Why do you want to use the getInterface method?  
getAttribute will work correctly anyway. There are some other problems 
with you code however - see comments      

> 
> Hi,
> I am not able to retrieve DOM attribute node name and value. Could someone throw
> light, specially getInterface and the feature to be provided as a parameter to
> this method.
> 
> Here is my xml and code to retrieve attribute.
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!-- Configuration file -->
> <configparameters>
>      <param name="ServerId">6</param>
>      <param name="NumThreads">10</param>
>      <param name="DbDsn">Wave3db</param>
>      <param name="DbServer">139.85.235.60</param>
>      <param name="DbServerPort">3306</param>
>      <param name="DbName">wave3db</param>
>      <param name="Dbdriver">{MySQL ODBC 3.51 Driver}</param>
>      <param name="DbUserName">user</param>
>      <param name="DbPassword">password</param>
>      <param name="DbNumOfConnections">2</param>
> </configparameters>
> 
this loop always selects the same param node
 
> for (INT32 i= 0; i < numParamNodes; i++)
> {
>       DOMElement* pDomElem = mDomDoc->getDocumentElement();
>       DOMNode* pTemp = mDomDoc->getDocumentElement()->getFirstChild();
> 
>       DOMNode * N = pTemp->getInterface (XMLString::transcode("attributes")) ;
> 
>     //  tried to get attribute using getAttribute
>    //    const XMLCh* test =
> pDomElem->getAttribute(XMLString::transcode("name"));

there is no attribute on configparameters. I think you meant pTemp. This 
will then work.


>    //   char* name3 = XMLString::transcode(test);
> 
>       const XMLCh* temp2 = pTemp->getNodeName();
>       char* name2 = XMLString::transcode (temp2);
> 
>       const XMLCh* temp1 = pTemp->getNodeValue();
>       char* value1 = XMLString::transcode (temp1);
> }


perhaps a loop something like this:

DOMElement *pDomElem = mDOMDoc->getDocumentElement();
DOMElement *temp = (DOMElement 
*) pDOMElem->getFirstChild()->getNextSibling();
for(INT32 i = 0; i < numParamNodes; i++) {
        DOMAttribute *attr = 
temp->getAttibute(XMLString::transcode("name"));

        //do something with attr

        temp = (DOMElement *)temp->getNextSibling()->getNextSibling();
}


note - text nodes are nodes getFirstChild on the doc ele will return a 
text node unless you have a DTD and certain options are set.

hope this helps,


Gareth


-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to