return JavaDOMGlobals::CreateNodeSubtype(env, (nsIDOMNode*)elements);
jobject jret = env->AllocObject(JavaDOMGlobals::nodeListClass); if (!jret) { JavaDOMGlobals::ThrowException(env, "Document.getElementsByTagNameNS: failed to allocate object"); return NULL; }  env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) elements); if (env->ExceptionOccurred()) { JavaDOMGlobals::ThrowException(env, "Document.getElementsByTagNameNS: failed to set node ptr"); return NULL; }  elements->AddRef(); return jret;
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagNameNS  (JNIEnv *env, jobject jthis, jstring jnamespaceURI, jstring jlocalName){  nsIDOMDocument* doc = (nsIDOMDocument*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!doc || !jnamespaceURI || !jlocalName) {    JavaDOMGlobals::ThrowException(env,      "Document.getElementsByTagNameNS: NULL pointer");    return NULL;  }  nsString* namespaceURI = JavaDOMGlobals::GetUnicode(env, jnamespaceURI);  if (!namespaceURI)    return NULL;  nsString* localName = JavaDOMGlobals::GetUnicode(env, jlocalName);  if (!localName) {    nsString::Recycle(namespaceURI);    return NULL;  }  nsIDOMNodeList* elements = nsnull;  nsresult rv = doc->GetElementsByTagNameNS(*namespaceURI, *localName, &elements);    nsString::Recycle(namespaceURI);  nsString::Recycle(localName);  if (NS_FAILED(rv) || !elements) {    JavaDOMGlobals::ThrowException(env,      "Document.getElementsByTagNameNS: failed", rv);    return NULL;  }  return JavaDOMGlobals::CreateNodeSubtype(env, (nsIDOMNode*)elements);}