ganga
December 17th, 2002, 06:42 AM
Platform Windows NT Workstation-(SP6), Visual C++ 6.0 - (SP5), IE6.0, MSXML3 (SP2)
Hello,
We are using MSXML3 SAX Parser for reading the XML file. The SAX Parser returns attribute list. The function used for getting attributes is given below ,which returns the count of attribute as 1, where as the total count of attributes present in the XML file is 3.
I have searched through MSDN, but could not find this as a documented problem. Am I doing something wrong or is this a known problem with a work around.
1) XML Data to be parsed:
<Code ID="850" Part="1" User="NO">
</Code>
2)
class CMySAXContentHandler : public ISAXContentHandler,
public ISAXErrorHandler
{
//overriden startElement handler
virtual HRESULT STDMETHODCALLTYPE startElement(
const wchar_t* pwchNSURI, int nNSURILen,
const wchar_t* pwchLocalName, int nLocalNameLen,
const wchar_t* pwchQName, int nQNameLen,
ISAXAttributes* pAttributes);
};
HRESULT STDMETHODCALLTYPE CMySAXContentHandler::startElement(
const wchar_t* pwchNSURI, int nNSURILen,
const wchar_t* pwchLocalName, int nLocalNameLen,
const wchar_t* pwchQName, int nQNameLen,
ISAXAttributes* pAttributes)
{
int nAttrCount = 0;
//CHECK_HR is my macro to check HRESULT
CHECK_HR(pAttributes->getLength(&nAttrCount),
"Error in ISAXAttributes::getLength", PROGRAM_ERROR);
/*********//PROBLEM IS HERE- nAttrCount is 1 instead of 3*************/
for(int nIndex = 0; nIndex < nAttrCount; nIndex++)
{
//code to get attribute name and corresponding value
//iterates fewer times than total number of attributes
//present in the data
}
return S_OK;
}
Thank you for your responses.
Regards
Ganga
Hello,
We are using MSXML3 SAX Parser for reading the XML file. The SAX Parser returns attribute list. The function used for getting attributes is given below ,which returns the count of attribute as 1, where as the total count of attributes present in the XML file is 3.
I have searched through MSDN, but could not find this as a documented problem. Am I doing something wrong or is this a known problem with a work around.
1) XML Data to be parsed:
<Code ID="850" Part="1" User="NO">
</Code>
2)
class CMySAXContentHandler : public ISAXContentHandler,
public ISAXErrorHandler
{
//overriden startElement handler
virtual HRESULT STDMETHODCALLTYPE startElement(
const wchar_t* pwchNSURI, int nNSURILen,
const wchar_t* pwchLocalName, int nLocalNameLen,
const wchar_t* pwchQName, int nQNameLen,
ISAXAttributes* pAttributes);
};
HRESULT STDMETHODCALLTYPE CMySAXContentHandler::startElement(
const wchar_t* pwchNSURI, int nNSURILen,
const wchar_t* pwchLocalName, int nLocalNameLen,
const wchar_t* pwchQName, int nQNameLen,
ISAXAttributes* pAttributes)
{
int nAttrCount = 0;
//CHECK_HR is my macro to check HRESULT
CHECK_HR(pAttributes->getLength(&nAttrCount),
"Error in ISAXAttributes::getLength", PROGRAM_ERROR);
/*********//PROBLEM IS HERE- nAttrCount is 1 instead of 3*************/
for(int nIndex = 0; nIndex < nAttrCount; nIndex++)
{
//code to get attribute name and corresponding value
//iterates fewer times than total number of attributes
//present in the data
}
return S_OK;
}
Thank you for your responses.
Regards
Ganga