[MSXML3] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / reactos / dll / win32 / msxml3 / element.c
index 120530c..5addf33 100644 (file)
@@ -1182,7 +1182,9 @@ static HRESULT WINAPI domelem_getAttribute(
     domelem *This = impl_from_IXMLDOMElement( iface );
     xmlNodePtr element;
     xmlChar *xml_name, *xml_value = NULL;
+    xmlChar *local, *prefix;
     HRESULT hr = S_FALSE;
+    xmlNsPtr ns;
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value);
 
@@ -1201,7 +1203,28 @@ static HRESULT WINAPI domelem_getAttribute(
     if(!xmlValidateNameValue(xml_name))
         hr = E_FAIL;
     else
-        xml_value = xmlGetNsProp(element, xml_name, NULL);
+    {
+        if ((local = xmlSplitQName2(xml_name, &prefix)))
+        {
+            if (xmlStrEqual(prefix, BAD_CAST "xmlns"))
+            {
+                ns = xmlSearchNs(element->doc, element, local);
+                if (ns)
+                    xml_value = xmlStrdup(ns->href);
+            }
+            else
+            {
+                ns = xmlSearchNs(element->doc, element, prefix);
+                if (ns)
+                    xml_value = xmlGetNsProp(element, local, ns->href);
+            }
+
+            xmlFree(prefix);
+            xmlFree(local);
+        }
+        else
+            xml_value = xmlGetNsProp(element, xml_name, NULL);
+    }
 
     heap_free(xml_name);
     if(xml_value)
@@ -1263,7 +1286,12 @@ static HRESULT WINAPI domelem_setAttribute(
         xmlFree(local);
 
         if (ns)
-            return xmlStrEqual(ns->href, xml_value) ? S_OK : E_INVALIDARG;
+        {
+            int cmp = xmlStrEqual(ns->href, xml_value);
+            heap_free(xml_value);
+            heap_free(xml_name);
+            return cmp ? S_OK : E_INVALIDARG;
+        }
     }
 
     if (!xmlSetNsProp(element, NULL, xml_name, xml_value))