Commit 90cf2f1a authored by Mike Kaplinskiy's avatar Mike Kaplinskiy Committed by Alexandre Julliard

msxml: getElementsByTagName does not respect namespaces.

We can't just use //tagname; we have to do //*[local-name()='tagname'].
parent 152c0d4b
......@@ -1279,14 +1279,25 @@ static HRESULT WINAPI domdoc_getElementsByTagName(
BSTR tagName,
IXMLDOMNodeList** resultList )
{
static const WCHAR xpathformat[] =
{ '/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'','%','s','\'',']',0 };
domdoc *This = impl_from_IXMLDOMDocument2( iface );
LPWSTR szPattern;
HRESULT hr;
TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList);
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(2+lstrlenW(tagName)+1));
szPattern[0] = szPattern[1] = '/';
lstrcpyW(szPattern + 2, tagName);
if (tagName[0] == '*' && tagName[1] == 0)
{
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*4);
szPattern[0] = szPattern[1] = '/';
szPattern[2] = '*';
szPattern[3] = 0;
}
else
{
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(20+lstrlenW(tagName)+1));
wsprintfW(szPattern, xpathformat, tagName);
}
hr = queryresult_create((xmlNodePtr)get_doc(This), szPattern, resultList);
HeapFree(GetProcessHeap(), 0, szPattern);
......
......@@ -666,6 +666,8 @@ static HRESULT WINAPI domelem_getElementsByTagName(
IXMLDOMElement *iface,
BSTR bstrName, IXMLDOMNodeList** resultList)
{
static const WCHAR xpathformat[] =
{ '.','/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'','%','s','\'',']',0 };
domelem *This = impl_from_IXMLDOMElement( iface );
LPWSTR szPattern;
xmlNodePtr element;
......@@ -673,10 +675,19 @@ static HRESULT WINAPI domelem_getElementsByTagName(
TRACE("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), resultList);
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(3+lstrlenW(bstrName)+1));
szPattern[0] = '.';
szPattern[1] = szPattern[2] = '/';
lstrcpyW(szPattern+3, bstrName);
if (bstrName[0] == '*' && bstrName[1] == 0)
{
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*5);
szPattern[0] = '.';
szPattern[1] = szPattern[2] = '/';
szPattern[3] = '*';
szPattern[4] = 0;
}
else
{
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(21+lstrlenW(bstrName)+1));
wsprintfW(szPattern, xpathformat, bstrName);
}
TRACE("%s\n", debugstr_w(szPattern));
element = get_element(This);
......
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