diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index ab5f03ec492..d955926bb22 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -981,8 +981,29 @@ static HRESULT WINAPI domdoc_createAttribute( BSTR name, IXMLDOMAttribute** attribute ) { - FIXME("\n"); - return E_NOTIMPL; + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + xmlNodePtr xmlnode; + xmlChar *xml_name; + + TRACE("%p->(%s %p)\n", iface, debugstr_w(name), attribute); + + if(!attribute) + return E_INVALIDARG; + + *attribute = NULL; + + xml_name = xmlChar_from_wchar((WCHAR*)name); + xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); + HeapFree(GetProcessHeap(), 0, xml_name); + + if(!xmlnode) + return E_FAIL; + + xmlnode->doc = get_doc( This ); + + *attribute = (IXMLDOMAttribute*)create_attribute(xmlnode); + + return S_OK; } diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 7865d9b8af2..3084e330ce9 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -137,6 +137,8 @@ static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0}; static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 }; +static WCHAR szAttribute[] = {'A','t','t','r',0 }; + #define expect_bstr_eq_and_free(bstr, expect) { \ BSTR bstrExp = alloc_str_from_narrow(expect); \ ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \ @@ -337,6 +339,7 @@ static void test_domdoc( void ) IXMLDOMNode *node; IXMLDOMText *nodetext = NULL; IXMLDOMComment *node_comment = NULL; + IXMLDOMAttribute *node_attr = NULL; VARIANT_BOOL b; VARIANT var; BSTR str; @@ -508,6 +511,13 @@ static void test_domdoc( void ) ok( r == S_OK, "returns %08x\n", r ); IXMLDOMText_Release( node_comment ); + /* test Create Attribute */ + r = IXMLDOMDocument_createAttribute(doc, NULL, NULL); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMText_Release( node_attr); + r = IXMLDOMDocument_Release( doc ); ok( r == 0, "document ref count incorrect\n");