msxml3: Implement createAttribute.

This commit is contained in:
Alistair Leslie-Hughes 2008-01-04 09:11:27 +11:00 committed by Alexandre Julliard
parent 2e3f5243ca
commit 300191d58c
2 changed files with 33 additions and 2 deletions

View File

@ -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;
}

View File

@ -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");