I'm try to get the dom elements by tagname using npapi whith chrome, but the length of the result is always zero.
NPVariant tagName;
STRINGZ_TO_NPVARIANT("input", tagName);
NPVariant inputCollection;
if(!NPN_Invoke(m_pNPInstance, doc,NPN_GetStringIdentifier("getElementsByTagName"), &tagName, 1, &inputCollection))
{
outLog<<"get input error"<<endl;
}
NPVariant npvlength;
if (NPN_GetProperty(m_pNPInstance, NPVARIANT_TO_OBJECT(inputCollection), NPN_GetStringIdentifier("length"), &npvlength))
{
outLog<<npvlength.type<<"," <<npvlength.value.intValue<<endl;
}
the npvlength.value.intValue is always 0, but when i try to get the element it's ok. I can get the element and it's property.
NPVariant index;
INT32_TO_NPVARIANT(0, index);
NPVariant Item;
if (NPN_Invoke(m_pNPInstance, NPVARIANT_TO_OBJECT(inputCollection), NPN_GetStringIdentifier("item"), &index, 1, &Item))
{
NPVariant typeVal;
if (NPN_GetProperty(m_pNPInstance, NPVARIANT_TO_OBJECT(Item), NPN_GetStringIdentifier("type"), &typeVal))
{
outLog<<NPVARIANT_TO_STRING(typeVal).UTF8Characters<<endl;
}
}