Commit 79b27421 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

msxml3: Fix domelem_get_tagName to return a string with the namespace prefixed, if it is present.

parent 6dd935bc
......@@ -26,6 +26,7 @@
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "ole2.h"
#include "msxml2.h"
......@@ -440,6 +441,9 @@ static HRESULT WINAPI domelem_get_tagName(
{
domelem *This = impl_from_IXMLDOMElement( iface );
xmlNodePtr element;
DWORD len;
DWORD offset = 0;
LPWSTR str;
TRACE("%p\n", This );
......@@ -450,7 +454,20 @@ static HRESULT WINAPI domelem_get_tagName(
if ( !element )
return E_FAIL;
*p = bstr_from_xmlChar( element->name );
len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, NULL, 0 );
if (element->ns)
len += MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, NULL, 0 );
str = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
if ( !str )
return E_OUTOFMEMORY;
if (element->ns)
{
offset = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, str, len );
str[offset - 1] = ':';
}
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, str + offset, len - offset );
*p = SysAllocString( str );
HeapFree( GetProcessHeap(), 0, str );
return S_OK;
}
......
......@@ -61,6 +61,20 @@ static const WCHAR szComplete4[] = {
'<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
'<','/','l','c','>','\n',0
};
static const WCHAR szComplete5[] = {
'<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
'<','S',':','s','c','o','p','e','>',
'<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
'<','/','S',':','s','c','o','p','e','>',
'<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
'<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
'c','o','m','p','u','t','e','r',
'<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
'<','/','S',':','s','e','a','r','c','h','>',0
};
static const WCHAR szNonExistentFile[] = {
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
};
......@@ -539,6 +553,38 @@ todo_wine
IXMLDOMNodeList_Release( list );
if (element)
IXMLDOMElement_Release( element );
b = FALSE;
str = SysAllocString( szComplete5 );
r = IXMLDOMDocument_loadXML( doc, str, &b );
ok( r == S_OK, "loadXML failed\n");
ok( b == VARIANT_TRUE, "failed to load XML string\n");
SysFreeString( str );
b = 1;
r = IXMLDOMNode_hasChildNodes( doc, &b );
ok( r == S_OK, "hasChildNoes bad return\n");
ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
r = IXMLDOMDocument_get_documentElement( doc, &element );
ok( r == S_OK, "should be a document element\n");
ok( element != NULL, "should be an element\n");
if (element)
{
static const WCHAR szSSearch[] = {'S',':','s','e','a','r','c','h',0};
BSTR tag = NULL;
/* check if the tag is correct */
r = IXMLDOMElement_get_tagName( element, &tag );
ok( r == S_OK, "couldn't get tag name\n");
ok( tag != NULL, "tag was null\n");
ok( !lstrcmpW( tag, szSSearch ), "incorrect tag name\n");
SysFreeString( tag );
}
if (element)
IXMLDOMElement_Release( element );
if (doc)
IXMLDOMDocument_Release( doc );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment