Nickolay Ponomarev ??:
> On 9/24/07, Brightman <[EMAIL PROTECTED]> wrote:
>
>> my code as follow,but it does't work :(
>>
>>
> "Doesn't work" meaning what exactly?
>
> Did you check that "a" elements are lowercase in the DOM inspector?
>
> BTW, note that you don't check for any return values, meaning you'll
> crash on OOM and if the nodelist changes while you iterate it
> (assuming you'll add more interesting code in the loop body).
>
> Nickolay
>
thank u very much!
"a" or "A", the length of nodelist is 0
but GetElementsByTagName(NS_LITERAL_STRING("body"),....),
nodelist->GetLength() return 1.
>
>> nsCOMPtr<nsIDOMDocument> domDoc;
>> nsresult res = mNavigation->GetDocument(getter_AddRefs(domDoc));
>> nsCOMPtr<nsIDOMNodeList> nodelist;
>> res = domDoc-
>>
>>> GetElementsByTagName(NS_LITERAL_STRING("a"),getter_AddRefs(nodelist));
>>>
>> PRUint32 index;
>> PRUint32 length;
>> res = nodelist->GetLength(&length);
>> printf("Get nodelist num[%d] res[%d]\n",length,res);
>> NS_NAMED_LITERAL_STRING(hrefAttr,"href");
>> for(index=0;index<length;index++)
>> {
>> nsCOMPtr<nsIDOMNode> node;
>> res=nodelist->Item(index,getter_AddRefs(node));
>> nsAutoString href;
>> nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(node);
>> res = elt->GetAttribute(hrefAttr,href);
>> printf("node[%d] %s res[%d]\n",index,href.get(),res);
>> }
>>
>>
>> _______________________________________________
>> dev-embedding mailing list
>> [email protected]
>> https://lists.mozilla.org/listinfo/dev-embedding
>>
>>
>>
>
>
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding