2 * DOM Document implementation
4 * Copyright 2005 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "msxml_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
41 typedef struct _domelem
44 const struct IXMLDOMElementVtbl
*lpVtbl
;
48 static inline domelem
*impl_from_IXMLDOMElement( IXMLDOMElement
*iface
)
50 return (domelem
*)((char*)iface
- FIELD_OFFSET(domelem
, lpVtbl
));
53 static inline xmlNodePtr
get_element( const domelem
*This
)
55 return This
->node
.node
;
58 static HRESULT WINAPI
domelem_QueryInterface(
59 IXMLDOMElement
*iface
,
63 domelem
*This
= impl_from_IXMLDOMElement( iface
);
65 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
67 if ( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
68 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
69 IsEqualGUID( riid
, &IID_IDispatch
) ||
70 IsEqualGUID( riid
, &IID_IUnknown
) )
72 *ppvObject
= &This
->lpVtbl
;
74 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
76 return *ppvObject
? S_OK
: E_NOINTERFACE
;
80 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
84 IUnknown_AddRef( (IUnknown
*)*ppvObject
);
88 static ULONG WINAPI
domelem_AddRef(
89 IXMLDOMElement
*iface
)
91 domelem
*This
= impl_from_IXMLDOMElement( iface
);
92 LONG ref
= InterlockedIncrement(&This
->ref
);
94 TRACE("(%p) ref=%d\n", This
, ref
);
99 static ULONG WINAPI
domelem_Release(
100 IXMLDOMElement
*iface
)
102 domelem
*This
= impl_from_IXMLDOMElement( iface
);
103 ULONG ref
= InterlockedDecrement(&This
->ref
);
105 TRACE("(%p) ref=%d\n", This
, ref
);
108 destroy_xmlnode(&This
->node
);
115 static HRESULT WINAPI
domelem_GetTypeInfoCount(
116 IXMLDOMElement
*iface
,
119 domelem
*This
= impl_from_IXMLDOMElement( iface
);
121 TRACE("(%p)->(%p)\n", This
, pctinfo
);
128 static HRESULT WINAPI
domelem_GetTypeInfo(
129 IXMLDOMElement
*iface
,
130 UINT iTInfo
, LCID lcid
,
131 ITypeInfo
** ppTInfo
)
133 domelem
*This
= impl_from_IXMLDOMElement( iface
);
136 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
138 hr
= get_typeinfo(IXMLDOMElement_tid
, ppTInfo
);
143 static HRESULT WINAPI
domelem_GetIDsOfNames(
144 IXMLDOMElement
*iface
,
145 REFIID riid
, LPOLESTR
* rgszNames
,
146 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
148 domelem
*This
= impl_from_IXMLDOMElement( iface
);
152 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
155 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
158 hr
= get_typeinfo(IXMLDOMElement_tid
, &typeinfo
);
161 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
162 ITypeInfo_Release(typeinfo
);
168 static HRESULT WINAPI
domelem_Invoke(
169 IXMLDOMElement
*iface
,
170 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
171 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
172 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
174 domelem
*This
= impl_from_IXMLDOMElement( iface
);
178 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
179 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
181 hr
= get_typeinfo(IXMLDOMElement_tid
, &typeinfo
);
184 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
185 pVarResult
, pExcepInfo
, puArgErr
);
186 ITypeInfo_Release(typeinfo
);
192 static HRESULT WINAPI
domelem_get_nodeName(
193 IXMLDOMElement
*iface
,
196 domelem
*This
= impl_from_IXMLDOMElement( iface
);
198 TRACE("(%p)->(%p)\n", This
, p
);
200 return node_get_nodeName(&This
->node
, p
);
203 static HRESULT WINAPI
domelem_get_nodeValue(
204 IXMLDOMElement
*iface
,
207 domelem
*This
= impl_from_IXMLDOMElement( iface
);
209 TRACE("(%p)->(%p)\n", This
, value
);
214 V_VT(value
) = VT_NULL
;
215 V_BSTR(value
) = NULL
; /* tests show that we should do this */
219 static HRESULT WINAPI
domelem_put_nodeValue(
220 IXMLDOMElement
*iface
,
223 domelem
*This
= impl_from_IXMLDOMElement( iface
);
224 TRACE("(%p)->(v%d)\n", This
, V_VT(&value
));
228 static HRESULT WINAPI
domelem_get_nodeType(
229 IXMLDOMElement
*iface
,
230 DOMNodeType
* domNodeType
)
232 domelem
*This
= impl_from_IXMLDOMElement( iface
);
234 TRACE("(%p)->(%p)\n", This
, domNodeType
);
236 *domNodeType
= NODE_ELEMENT
;
240 static HRESULT WINAPI
domelem_get_parentNode(
241 IXMLDOMElement
*iface
,
242 IXMLDOMNode
** parent
)
244 domelem
*This
= impl_from_IXMLDOMElement( iface
);
246 TRACE("(%p)->(%p)\n", This
, parent
);
248 return node_get_parent(&This
->node
, parent
);
251 static HRESULT WINAPI
domelem_get_childNodes(
252 IXMLDOMElement
*iface
,
253 IXMLDOMNodeList
** outList
)
255 domelem
*This
= impl_from_IXMLDOMElement( iface
);
257 TRACE("(%p)->(%p)\n", This
, outList
);
259 return node_get_child_nodes(&This
->node
, outList
);
262 static HRESULT WINAPI
domelem_get_firstChild(
263 IXMLDOMElement
*iface
,
264 IXMLDOMNode
** domNode
)
266 domelem
*This
= impl_from_IXMLDOMElement( iface
);
268 TRACE("(%p)->(%p)\n", This
, domNode
);
270 return node_get_first_child(&This
->node
, domNode
);
273 static HRESULT WINAPI
domelem_get_lastChild(
274 IXMLDOMElement
*iface
,
275 IXMLDOMNode
** domNode
)
277 domelem
*This
= impl_from_IXMLDOMElement( iface
);
279 TRACE("(%p)->(%p)\n", This
, domNode
);
281 return node_get_last_child(&This
->node
, domNode
);
284 static HRESULT WINAPI
domelem_get_previousSibling(
285 IXMLDOMElement
*iface
,
286 IXMLDOMNode
** domNode
)
288 domelem
*This
= impl_from_IXMLDOMElement( iface
);
290 TRACE("(%p)->(%p)\n", This
, domNode
);
292 return node_get_previous_sibling(&This
->node
, domNode
);
295 static HRESULT WINAPI
domelem_get_nextSibling(
296 IXMLDOMElement
*iface
,
297 IXMLDOMNode
** domNode
)
299 domelem
*This
= impl_from_IXMLDOMElement( iface
);
301 TRACE("(%p)->(%p)\n", This
, domNode
);
303 return node_get_next_sibling(&This
->node
, domNode
);
306 static HRESULT WINAPI
domelem_get_attributes(
307 IXMLDOMElement
*iface
,
308 IXMLDOMNamedNodeMap
** attributeMap
)
310 domelem
*This
= impl_from_IXMLDOMElement( iface
);
312 TRACE("(%p)->(%p)\n", This
, attributeMap
);
314 *attributeMap
= create_nodemap((IXMLDOMNode
*)&This
->lpVtbl
);
318 static HRESULT WINAPI
domelem_insertBefore(
319 IXMLDOMElement
*iface
,
320 IXMLDOMNode
* newNode
, VARIANT refChild
,
321 IXMLDOMNode
** outOldNode
)
323 domelem
*This
= impl_from_IXMLDOMElement( iface
);
325 TRACE("(%p)->(%p x%d %p)\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
327 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
330 static HRESULT WINAPI
domelem_replaceChild(
331 IXMLDOMElement
*iface
,
332 IXMLDOMNode
* newNode
,
333 IXMLDOMNode
* oldNode
,
334 IXMLDOMNode
** outOldNode
)
336 domelem
*This
= impl_from_IXMLDOMElement( iface
);
338 TRACE("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
340 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
343 static HRESULT WINAPI
domelem_removeChild(
344 IXMLDOMElement
*iface
,
345 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
347 domelem
*This
= impl_from_IXMLDOMElement( iface
);
348 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), domNode
, oldNode
);
351 static HRESULT WINAPI
domelem_appendChild(
352 IXMLDOMElement
*iface
,
353 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
355 domelem
*This
= impl_from_IXMLDOMElement( iface
);
356 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, outNewNode
);
359 static HRESULT WINAPI
domelem_hasChildNodes(
360 IXMLDOMElement
*iface
,
363 domelem
*This
= impl_from_IXMLDOMElement( iface
);
364 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), pbool
);
367 static HRESULT WINAPI
domelem_get_ownerDocument(
368 IXMLDOMElement
*iface
,
369 IXMLDOMDocument
** domDocument
)
371 domelem
*This
= impl_from_IXMLDOMElement( iface
);
372 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), domDocument
);
375 static HRESULT WINAPI
domelem_cloneNode(
376 IXMLDOMElement
*iface
,
377 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
379 domelem
*This
= impl_from_IXMLDOMElement( iface
);
380 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
381 return node_clone( &This
->node
, deep
, outNode
);
384 static HRESULT WINAPI
domelem_get_nodeTypeString(
385 IXMLDOMElement
*iface
,
388 domelem
*This
= impl_from_IXMLDOMElement( iface
);
389 static const WCHAR elementW
[] = {'e','l','e','m','e','n','t',0};
391 TRACE("(%p)->(%p)\n", This
, p
);
393 return return_bstr(elementW
, p
);
396 static HRESULT WINAPI
domelem_get_text(
397 IXMLDOMElement
*iface
,
400 domelem
*This
= impl_from_IXMLDOMElement( iface
);
401 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), p
);
404 static HRESULT WINAPI
domelem_put_text(
405 IXMLDOMElement
*iface
,
408 domelem
*This
= impl_from_IXMLDOMElement( iface
);
409 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
410 return node_put_text( &This
->node
, p
);
413 static HRESULT WINAPI
domelem_get_specified(
414 IXMLDOMElement
*iface
,
415 VARIANT_BOOL
* isSpecified
)
417 domelem
*This
= impl_from_IXMLDOMElement( iface
);
418 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
419 *isSpecified
= VARIANT_TRUE
;
423 static HRESULT WINAPI
domelem_get_definition(
424 IXMLDOMElement
*iface
,
425 IXMLDOMNode
** definitionNode
)
427 domelem
*This
= impl_from_IXMLDOMElement( iface
);
428 FIXME("(%p)->(%p)\n", This
, definitionNode
);
432 static HRESULT WINAPI
domelem_get_nodeTypedValue(
433 IXMLDOMElement
*iface
,
436 domelem
*This
= impl_from_IXMLDOMElement( iface
);
437 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
440 static HRESULT WINAPI
domelem_put_nodeTypedValue(
441 IXMLDOMElement
*iface
,
444 domelem
*This
= impl_from_IXMLDOMElement( iface
);
448 TRACE("(%p)\n", This
);
450 /* for untyped node coerce to BSTR and set */
451 if (IXMLDOMElement_get_dataType(iface
, &type
) == S_FALSE
)
453 if (V_VT(&value
) != VT_BSTR
)
455 hr
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
458 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
459 VariantClear(&value
);
463 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
467 FIXME("not implemented for typed nodes. type %s\n", debugstr_w(V_BSTR(&value
)));
475 static HRESULT WINAPI
domelem_get_dataType(
476 IXMLDOMElement
*iface
,
479 domelem
*This
= impl_from_IXMLDOMElement( iface
);
480 xmlChar
*pVal
= xmlGetNsProp(get_element(This
), (const xmlChar
*)"dt",
481 (const xmlChar
*)"urn:schemas-microsoft-com:datatypes");
483 TRACE("(%p)->(%p)\n", This
, typename
);
485 V_VT(typename
) = VT_NULL
;
489 V_VT(typename
) = VT_BSTR
;
490 V_BSTR(typename
) = bstr_from_xmlChar( pVal
);
494 return (V_VT(typename
) != VT_NULL
) ? S_OK
: S_FALSE
;
497 static HRESULT WINAPI
domelem_put_dataType(
498 IXMLDOMElement
*iface
,
501 domelem
*This
= impl_from_IXMLDOMElement( iface
);
502 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), p
);
505 static HRESULT WINAPI
domelem_get_xml(
506 IXMLDOMElement
*iface
,
509 domelem
*This
= impl_from_IXMLDOMElement( iface
);
511 TRACE("(%p)->(%p)\n", This
, p
);
513 return node_get_xml(&This
->node
, TRUE
, FALSE
, p
);
516 static HRESULT WINAPI
domelem_transformNode(
517 IXMLDOMElement
*iface
,
518 IXMLDOMNode
* domNode
, BSTR
* p
)
520 domelem
*This
= impl_from_IXMLDOMElement( iface
);
521 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), domNode
, p
);
524 static HRESULT WINAPI
domelem_selectNodes(
525 IXMLDOMElement
*iface
,
526 BSTR p
, IXMLDOMNodeList
** outList
)
528 domelem
*This
= impl_from_IXMLDOMElement( iface
);
529 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), p
, outList
);
532 static HRESULT WINAPI
domelem_selectSingleNode(
533 IXMLDOMElement
*iface
,
534 BSTR p
, IXMLDOMNode
** outNode
)
536 domelem
*This
= impl_from_IXMLDOMElement( iface
);
537 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), p
, outNode
);
540 static HRESULT WINAPI
domelem_get_parsed(
541 IXMLDOMElement
*iface
,
542 VARIANT_BOOL
* isParsed
)
544 domelem
*This
= impl_from_IXMLDOMElement( iface
);
545 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
546 *isParsed
= VARIANT_TRUE
;
550 static HRESULT WINAPI
domelem_get_namespaceURI(
551 IXMLDOMElement
*iface
,
554 domelem
*This
= impl_from_IXMLDOMElement( iface
);
555 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), p
);
558 static HRESULT WINAPI
domelem_get_prefix(
559 IXMLDOMElement
*iface
,
562 domelem
*This
= impl_from_IXMLDOMElement( iface
);
563 TRACE("(%p)->(%p)\n", This
, prefix
);
564 return node_get_prefix( &This
->node
, prefix
);
567 static HRESULT WINAPI
domelem_get_baseName(
568 IXMLDOMElement
*iface
,
571 domelem
*This
= impl_from_IXMLDOMElement( iface
);
572 TRACE("(%p)->(%p)\n", This
, name
);
573 return node_get_base_name( &This
->node
, name
);
576 static HRESULT WINAPI
domelem_transformNodeToObject(
577 IXMLDOMElement
*iface
,
578 IXMLDOMNode
* domNode
, VARIANT var1
)
580 domelem
*This
= impl_from_IXMLDOMElement( iface
);
581 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), domNode
, var1
);
584 static HRESULT WINAPI
domelem_get_tagName(
585 IXMLDOMElement
*iface
,
588 domelem
*This
= impl_from_IXMLDOMElement( iface
);
590 const xmlChar
*prefix
;
593 TRACE("(%p)->(%p)\n", This
, p
);
595 if (!p
) return E_INVALIDARG
;
597 element
= get_element( This
);
601 prefix
= element
->ns
? element
->ns
->prefix
: NULL
;
602 qname
= xmlBuildQName(element
->name
, prefix
, NULL
, 0);
604 *p
= bstr_from_xmlChar(qname
);
605 if (qname
!= element
->name
) xmlFree(qname
);
607 return *p
? S_OK
: E_OUTOFMEMORY
;
610 static HRESULT WINAPI
domelem_getAttribute(
611 IXMLDOMElement
*iface
,
612 BSTR name
, VARIANT
* value
)
614 domelem
*This
= impl_from_IXMLDOMElement( iface
);
616 xmlChar
*xml_name
, *xml_value
= NULL
;
617 HRESULT hr
= S_FALSE
;
619 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(name
), value
);
624 element
= get_element( This
);
628 V_BSTR(value
) = NULL
;
629 V_VT(value
) = VT_NULL
;
631 xml_name
= xmlChar_from_wchar( name
);
633 if(!xmlValidateNameValue(xml_name
))
636 xml_value
= xmlGetNsProp(element
, xml_name
, NULL
);
641 V_VT(value
) = VT_BSTR
;
642 V_BSTR(value
) = bstr_from_xmlChar( xml_value
);
650 static HRESULT WINAPI
domelem_setAttribute(
651 IXMLDOMElement
*iface
,
652 BSTR name
, VARIANT value
)
654 domelem
*This
= impl_from_IXMLDOMElement( iface
);
656 xmlChar
*xml_name
, *xml_value
;
660 TRACE("(%p)->(%s var)\n", This
, debugstr_w(name
));
662 element
= get_element( This
);
667 hr
= VariantChangeType(&var
, &value
, 0, VT_BSTR
);
670 FIXME("VariantChangeType failed\n");
674 xml_name
= xmlChar_from_wchar( name
);
675 xml_value
= xmlChar_from_wchar( V_BSTR(&var
) );
677 if(!xmlSetNsProp(element
, NULL
, xml_name
, xml_value
))
680 heap_free(xml_value
);
687 static HRESULT WINAPI
domelem_removeAttribute(
688 IXMLDOMElement
*iface
,
691 domelem
*This
= impl_from_IXMLDOMElement( iface
);
692 IXMLDOMNamedNodeMap
*attr
;
695 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
697 hr
= IXMLDOMElement_get_attributes(iface
, &attr
);
698 if (hr
!= S_OK
) return hr
;
700 hr
= IXMLDOMNamedNodeMap_removeNamedItem(attr
, p
, NULL
);
701 IXMLDOMNamedNodeMap_Release(attr
);
706 static HRESULT WINAPI
domelem_getAttributeNode(
707 IXMLDOMElement
*iface
,
708 BSTR p
, IXMLDOMAttribute
** attributeNode
)
710 domelem
*This
= impl_from_IXMLDOMElement( iface
);
715 HRESULT hr
= S_FALSE
;
717 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), attributeNode
);
722 *attributeNode
= NULL
;
724 element
= get_element( This
);
728 xml_name
= xmlChar_from_wchar(p
);
730 if(!xmlValidateNameValue(xml_name
))
736 attr
= xmlHasProp(element
, xml_name
);
738 unk
= create_attribute((xmlNodePtr
)attr
);
739 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMAttribute
, (void**)attributeNode
);
740 IUnknown_Release(unk
);
748 static HRESULT WINAPI
domelem_setAttributeNode(
749 IXMLDOMElement
*iface
,
750 IXMLDOMAttribute
* attribute
,
751 IXMLDOMAttribute
** old
)
753 domelem
*This
= impl_from_IXMLDOMElement( iface
);
754 xmlChar
*name
, *value
;
760 FIXME("(%p)->(%p %p): semi-stub\n", This
, attribute
, old
);
762 if (!attribute
) return E_INVALIDARG
;
764 if (old
) *old
= NULL
;
766 hr
= IXMLDOMAttribute_get_nodeName(attribute
, &nameW
);
767 if (hr
!= S_OK
) return hr
;
769 hr
= IXMLDOMAttribute_get_nodeValue(attribute
, &valueW
);
772 SysFreeString(nameW
);
776 TRACE("attribute: %s=%s\n", debugstr_w(nameW
), debugstr_w(V_BSTR(&valueW
)));
778 hr
= IXMLDOMAttribute_get_prefix(attribute
, &prefix
);
781 FIXME("namespaces not supported: %s\n", debugstr_w(prefix
));
782 SysFreeString(prefix
);
785 name
= xmlChar_from_wchar(nameW
);
786 value
= xmlChar_from_wchar(V_BSTR(&valueW
));
790 SysFreeString(nameW
);
791 VariantClear(&valueW
);
794 return E_OUTOFMEMORY
;
797 attr
= xmlSetNsProp(get_element(This
), NULL
, name
, value
);
799 SysFreeString(nameW
);
800 VariantClear(&valueW
);
804 return attr
? S_OK
: E_FAIL
;
807 static HRESULT WINAPI
domelem_removeAttributeNode(
808 IXMLDOMElement
*iface
,
809 IXMLDOMAttribute
* domAttribute
,
810 IXMLDOMAttribute
** attributeNode
)
812 domelem
*This
= impl_from_IXMLDOMElement( iface
);
813 FIXME("(%p)->(%p %p)\n", This
, domAttribute
, attributeNode
);
817 static HRESULT WINAPI
domelem_getElementsByTagName(
818 IXMLDOMElement
*iface
,
819 BSTR tagName
, IXMLDOMNodeList
** resultList
)
821 domelem
*This
= impl_from_IXMLDOMElement( iface
);
825 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(tagName
), resultList
);
827 if (!tagName
|| !resultList
) return E_INVALIDARG
;
828 if (!(element
= get_element(This
))) return E_FAIL
;
830 if (tagName
[0] == '*' && tagName
[1] == 0)
832 static const WCHAR formatallW
[] = {'/','/','*',0};
833 hr
= queryresult_create(element
, formatallW
, resultList
);
837 static const WCHAR xpathformat
[] =
838 { '/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'' };
839 static const WCHAR closeW
[] = { '\'',']',0 };
845 length
= lstrlenW(tagName
);
847 /* without two WCHARs from format specifier */
848 ptr
= pattern
= heap_alloc(sizeof(xpathformat
) + length
*sizeof(WCHAR
) + sizeof(closeW
));
850 memcpy(ptr
, xpathformat
, sizeof(xpathformat
));
851 ptr
+= sizeof(xpathformat
)/sizeof(WCHAR
);
852 memcpy(ptr
, tagName
, length
*sizeof(WCHAR
));
854 memcpy(ptr
, closeW
, sizeof(closeW
));
856 TRACE("%s\n", debugstr_w(pattern
));
857 hr
= queryresult_create(element
, pattern
, resultList
);
864 static HRESULT WINAPI
domelem_normalize(
865 IXMLDOMElement
*iface
)
867 domelem
*This
= impl_from_IXMLDOMElement( iface
);
872 static const struct IXMLDOMElementVtbl domelem_vtbl
=
874 domelem_QueryInterface
,
877 domelem_GetTypeInfoCount
,
879 domelem_GetIDsOfNames
,
881 domelem_get_nodeName
,
882 domelem_get_nodeValue
,
883 domelem_put_nodeValue
,
884 domelem_get_nodeType
,
885 domelem_get_parentNode
,
886 domelem_get_childNodes
,
887 domelem_get_firstChild
,
888 domelem_get_lastChild
,
889 domelem_get_previousSibling
,
890 domelem_get_nextSibling
,
891 domelem_get_attributes
,
892 domelem_insertBefore
,
893 domelem_replaceChild
,
896 domelem_hasChildNodes
,
897 domelem_get_ownerDocument
,
899 domelem_get_nodeTypeString
,
902 domelem_get_specified
,
903 domelem_get_definition
,
904 domelem_get_nodeTypedValue
,
905 domelem_put_nodeTypedValue
,
906 domelem_get_dataType
,
907 domelem_put_dataType
,
909 domelem_transformNode
,
911 domelem_selectSingleNode
,
913 domelem_get_namespaceURI
,
915 domelem_get_baseName
,
916 domelem_transformNodeToObject
,
918 domelem_getAttribute
,
919 domelem_setAttribute
,
920 domelem_removeAttribute
,
921 domelem_getAttributeNode
,
922 domelem_setAttributeNode
,
923 domelem_removeAttributeNode
,
924 domelem_getElementsByTagName
,
928 static const tid_t domelem_iface_tids
[] = {
933 static dispex_static_data_t domelem_dispex
= {
940 IUnknown
* create_element( xmlNodePtr element
)
944 This
= heap_alloc( sizeof *This
);
948 This
->lpVtbl
= &domelem_vtbl
;
951 init_xmlnode(&This
->node
, element
, (IXMLDOMNode
*)&This
->lpVtbl
, &domelem_dispex
);
953 return (IUnknown
*) &This
->lpVtbl
;