Show
Ignore:
Timestamp:
10/10/08 08:36:03 (3 months ago)
Author:
tokuhirom
Message:

added doc.getElementById

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/llv8call/trunk/ext/libxml/document.cc

    r21003 r21068  
    175175    xmlFree(result); 
    176176    return str; 
     177END 
     178 
     179FUNCTION(getElementById) 
     180    ARG_COUNT(1); 
     181    ARG_str(id, 0); 
     182    EXTERNAL_DOC(); 
     183    xmlAttrPtr attr = xmlGetID(doc, (const xmlChar*)*id); 
     184    if (!attr) { 
     185        return Undefined(); 
     186    } else if (attr->type == XML_ATTRIBUTE_NODE) { 
     187        return CREATE_ATTR(doc, attr->parent); 
     188    } else if (attr->type == XML_ELEMENT_NODE) { 
     189        return createObject("Element", doc, (xmlNodePtr)attr); 
     190    } else { 
     191        return Undefined(); 
     192    } 
    177193END 
    178194 
     
    199215    BIND_IM("createComment",          createComment); 
    200216    BIND_IM("toString",               toString); 
     217    BIND_IM("getElementById",         getElementById); 
    201218    BIND_IM("close",                  _close); 
    202219    INTERNALCOUNT(2);