4 * Copyright 2007 James Hawkins
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
31 #include "wine/test.h"
33 #define ERROR_URL_NOT_FOUND 0x800c0006
35 static void test_xmlelem(void)
38 IXMLDocument *doc = NULL;
39 IXMLElement *element = NULL, *parent;
40 IXMLElement *child, *child2;
41 IXMLElementCollection *children;
43 VARIANT vIndex, vValue;
47 static const WCHAR propName[] = {'p','r','o','p',0};
48 static const WCHAR propVal[] = {'v','a','l',0};
49 static const WCHAR nextVal[] = {'n','e','x','t',0};
50 static const WCHAR noexist[] = {'n','o','e','x','i','s','t',0};
51 static const WCHAR crazyCase1[] = {'C','R','a','z','Y','c','A','S','E',0};
52 static const WCHAR crazyCase2[] = {'C','R','A','Z','Y','C','A','S','E',0};
54 hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
55 &IID_IXMLDocument, (LPVOID*)&doc);
56 ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
59 V_I4(&vType) = XMLELEMTYPE_ELEMENT;
60 V_VT(&vName) = VT_NULL;
61 hr = IXMLDocument_createElement(doc, vType, vName, &element);
62 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
63 ok(element != NULL, "Expected non-NULL element\n");
65 hr = IXMLElement_get_tagName(element, &str);
66 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
67 ok(lstrlenW(str) == 0, "Expected empty tag name\n");
70 parent = (IXMLElement *)0xdeadbeef;
71 hr = IXMLElement_get_parent(element, &parent);
72 ok(hr == 1, "Expected 1, got %08x\n", hr);
73 ok(parent == NULL, "Expected NULL parent\n");
75 str = SysAllocString(noexist);
76 hr = IXMLElement_getAttribute(element, str, &vValue);
77 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
78 ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
79 ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
80 VariantClear(&vValue);
83 str = SysAllocString(crazyCase1);
84 val = SysAllocString(propVal);
85 V_VT(&vValue) = VT_BSTR;
86 V_BSTR(&vValue) = val;
87 hr = IXMLElement_setAttribute(element, str, vValue);
88 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
92 str = SysAllocString(crazyCase2);
93 hr = IXMLElement_getAttribute(element, str, &vValue);
94 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
95 ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
96 ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
97 VariantClear(&vValue);
100 str = SysAllocString(propName);
101 val = SysAllocString(propVal);
102 V_VT(&vValue) = VT_BSTR;
103 V_BSTR(&vValue) = val;
104 hr = IXMLElement_setAttribute(element, str, vValue);
105 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
108 hr = IXMLElement_getAttribute(element, str, &vValue);
109 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
110 ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue));
111 ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n");
112 VariantClear(&vValue);
114 hr = IXMLElement_removeAttribute(element, str);
115 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
117 /* remove now nonexistent attribute */
118 hr = IXMLElement_removeAttribute(element, str);
119 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
121 hr = IXMLElement_getAttribute(element, str, &vValue);
122 ok(hr == 1, "Expected 1, got %08x\n", hr);
123 ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue));
124 ok(V_BSTR(&vValue) == NULL, "Expected null value\n");
126 VariantClear(&vValue);
128 children = (IXMLElementCollection *)0xdeadbeef;
129 hr = IXMLElement_get_children(element, &children);
130 ok(hr == 1, "Expected 1, got %08x\n", hr);
131 ok(children == NULL, "Expected NULL collection\n");
133 hr = IXMLElement_get_type(element, &type);
134 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
135 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
137 hr = IXMLElement_get_text(element, &str);
138 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
139 ok(lstrlenW(str) == 0, "Expected empty text\n");
142 /* put_text with an ELEMENT */
143 str = SysAllocString(propVal);
144 hr = IXMLElement_put_text(element, str);
145 ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
148 V_VT(&vType) = VT_I4;
149 V_I4(&vType) = XMLELEMTYPE_TEXT;
150 V_VT(&vName) = VT_NULL;
151 hr = IXMLDocument_createElement(doc, vType, vName, &child);
152 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
153 ok(child != NULL, "Expected non-NULL child\n");
155 hr = IXMLElement_addChild(element, child, 0, -1);
156 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
158 str = SysAllocString(propVal);
159 hr = IXMLElement_put_text(child, str);
160 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
163 parent = (IXMLElement *)0xdeadbeef;
164 hr = IXMLElement_get_parent(child, &parent);
165 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
166 ok(parent != element, "Expected parent != element\n");
168 hr = IXMLElement_get_type(parent, &type);
169 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
170 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
172 children = (IXMLElementCollection *)0xdeadbeef;
173 hr = IXMLElement_get_children(element, &children);
174 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
175 ok(children != NULL, "Expected non-NULL collection\n");
177 hr = IXMLElementCollection_get_length(children, &num_child);
178 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
179 ok(num_child == 1, "Expected 1, got %d\n", num_child);
181 V_VT(&vIndex) = VT_I4;
183 V_VT(&vName) = VT_ERROR;
184 V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
185 hr = IXMLElementCollection_item(children, vIndex, vName, (IDispatch **)&child2);
186 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
187 ok(child2 != NULL, "Expected non-NULL child\n");
189 hr = IXMLElement_get_type(child2, &type);
190 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
191 ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type);
193 hr = IXMLElement_get_text(element, &str);
194 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
195 ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
198 hr = IXMLElement_get_text(child2, &str);
199 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
200 ok(!lstrcmpW(str, propVal), "Expected 'val'\n");
203 /* try put_text on ELEMENT again, now that it has a text child */
204 str = SysAllocString(nextVal);
205 hr = IXMLElement_put_text(element, str);
206 ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr);
209 str = SysAllocString(nextVal);
210 hr = IXMLElement_put_text(child2, str);
211 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
214 hr = IXMLElement_get_text(element, &str);
215 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
216 ok(!lstrcmpW(str, nextVal), "Expected 'val'\n");
219 IXMLElement_Release(child2);
220 IXMLElementCollection_Release(children);
221 IXMLElement_Release(parent);
222 IXMLElement_Release(child);
223 IXMLElement_Release(element);
224 IXMLDocument_Release(doc);
227 static void create_xml_file(LPCSTR filename)
229 DWORD dwNumberOfBytesWritten;
230 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
231 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
233 static const char data[] =
234 "<?xml version=\"1.0\" ?>\n"
236 " <Number>1234</Number>\n"
237 " <Name>Captain Ahab</Name>\n"
240 WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
244 static void test_xmlelem_collection(void)
247 IUnknown *unk = NULL;
248 IXMLDocument *doc = NULL;
249 IXMLElement *element = NULL, *child;
250 IXMLElementCollection *collection = NULL;
251 IEnumVARIANT *enumVar = NULL;
252 CHAR pathA[MAX_PATH];
253 WCHAR path[MAX_PATH];
256 VARIANT var, vIndex, vName;
258 static const CHAR szBankXML[] = "bank.xml";
259 static const WCHAR szNumber[] = {'N','U','M','B','E','R',0};
260 static const WCHAR szName[] = {'N','A','M','E',0};
262 hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
263 &IID_IXMLDocument, (LPVOID*)&doc);
264 ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
266 create_xml_file(szBankXML);
267 GetFullPathNameA(szBankXML, MAX_PATH, pathA, NULL);
268 MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
270 url = SysAllocString(path);
271 hr = IXMLDocument_put_URL(doc, url);
272 ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
278 hr = IXMLDocument_get_root(doc, &element);
279 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
280 ok(element != NULL, "Expected non-NULL element\n");
282 hr = IXMLElement_get_children(element, &collection);
283 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
284 ok(collection != NULL, "Expected non-NULL collection\n");
286 hr = IXMLElementCollection_get_length(collection, NULL);
287 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
289 hr = IXMLElementCollection_get_length(collection, &length);
290 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
291 ok(length == 2, "Expected 2, got %d\n", length);
293 /* IXMLElementCollection:put_length does nothing */
294 hr = IXMLElementCollection_put_length(collection, -1);
295 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
297 hr = IXMLElementCollection_put_length(collection, 0);
298 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
300 hr = IXMLElementCollection_put_length(collection, 1);
301 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
303 hr = IXMLElementCollection_put_length(collection, 2);
304 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
306 hr = IXMLElementCollection_put_length(collection, 3);
307 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
309 hr = IXMLElementCollection_put_length(collection, 50);
310 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
312 /* make sure the length hasn't changed */
313 hr = IXMLElementCollection_get_length(collection, &length);
314 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
315 ok(length == 2, "Expected 2, got %d\n", length);
317 /* IXMLElementCollection implements IEnumVARIANT */
318 hr = IXMLElementCollection_QueryInterface(collection, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
319 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
320 ok(enumVar != NULL, "Expected non-NULL enumVar\n");
321 IEnumVARIANT_Release(enumVar);
323 hr = IXMLElementCollection_get__newEnum(collection, &unk);
324 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
325 ok(unk != NULL, "Expected non-NULL unk\n");
327 hr = IUnknown_QueryInterface(unk, &IID_IEnumVARIANT, (LPVOID *)&enumVar);
328 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
329 ok(enumVar != NULL, "Expected non-NULL enumVar\n");
330 IUnknown_Release(unk);
332 /* <Number>1234</Number> */
333 hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
334 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
335 ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
336 ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
338 hr = IUnknown_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
339 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
340 ok(child != NULL, "Expected non-NULL child\n");
344 hr = IXMLElement_get_type(child, &type);
345 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
346 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
348 hr = IXMLElement_get_tagName(child, &str);
349 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
350 ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
352 IXMLElement_Release(child);
354 /* <Name>Captain Ahab</Name> */
355 hr = IEnumVARIANT_Next(enumVar, 1, &var, &num_vars);
356 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
357 ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %d\n", V_VT(&var));
358 ok(num_vars == 1, "Expected 1, got %d\n", num_vars);
360 hr = IUnknown_QueryInterface(V_DISPATCH(&var), &IID_IXMLElement, (LPVOID *)&child);
361 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
362 ok(child != NULL, "Expected non-NULL child\n");
366 hr = IXMLElement_get_type(child, &type);
367 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
368 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
370 hr = IXMLElement_get_tagName(child, &str);
371 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
372 ok(!lstrcmpW(str, szName), "Expected NAME\n");
374 IXMLElement_Release(child);
376 /* <Number>1234</Number> */
377 V_VT(&vIndex) = VT_I4;
379 V_VT(&vName) = VT_ERROR;
380 V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
381 hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
382 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
383 ok(child != NULL, "Expected non-NULL child\n");
385 hr = IXMLElement_get_type(child, &type);
386 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
387 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
389 hr = IXMLElement_get_tagName(child, &str);
390 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
391 ok(!lstrcmpW(str, szNumber), "Expected NUMBER\n");
393 IXMLElement_Release(child);
395 /* <Name>Captain Ahab</Name> */
396 V_VT(&vIndex) = VT_I4;
398 V_VT(&vName) = VT_ERROR;
399 V_ERROR(&vName) = DISP_E_PARAMNOTFOUND;
400 hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
401 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
402 ok(child != NULL, "Expected non-NULL child\n");
404 hr = IXMLElement_get_type(child, &type);
405 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
406 ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type);
408 hr = IXMLElement_get_tagName(child, &str);
409 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
410 ok(!lstrcmpW(str, szName), "Expected NAME\n");
412 IXMLElement_Release(child);
415 hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
416 ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
417 ok(child == NULL, "Expected NULL child\n");
420 child = (IXMLElement *)0xdeadbeef;
421 hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child);
422 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
423 ok(child == NULL, "Expected NULL child\n");
425 IEnumVARIANT_Release(enumVar);
426 IXMLElement_Release(element);
427 IXMLElementCollection_Release(collection);
429 IXMLDocument_Release(doc);
430 DeleteFileA("bank.xml");
433 static void test_xmlelem_children(void)
435 IXMLDocument *doc = NULL;
436 IXMLElement *element = NULL, *child = NULL, *child2 = NULL;
437 IXMLElementCollection *collection = NULL;
438 VARIANT vType, vName, vIndex;
442 hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
443 &IID_IXMLDocument, (LPVOID*)&doc);
444 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
446 V_VT(&vType) = VT_I4;
447 V_I4(&vType) = XMLELEMTYPE_ELEMENT;
448 V_VT(&vName) = VT_NULL;
449 hr = IXMLDocument_createElement(doc, vType, vName, &element);
450 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
451 ok(element != NULL, "Expected non-NULL element\n");
453 V_VT(&vType) = VT_I4;
454 V_I4(&vType) = XMLELEMTYPE_TEXT;
455 V_VT(&vName) = VT_NULL;
456 hr = IXMLDocument_createElement(doc, vType, vName, &child);
457 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
458 ok(child != NULL, "Expected non-NULL child\n");
460 V_VT(&vType) = VT_I4;
461 V_I4(&vType) = XMLELEMTYPE_TEXT;
462 V_VT(&vName) = VT_NULL;
463 hr = IXMLDocument_createElement(doc, vType, vName, &child2);
464 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
465 ok(child2 != NULL, "Expected non-NULL child\n");
467 hr = IXMLElement_addChild(element, child, 0, -1);
468 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
470 hr = IXMLElement_get_children(element, &collection);
471 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
472 ok(collection != NULL, "Expected non-NULL collection\n");
475 hr = IXMLElementCollection_get_length(collection, &length);
476 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
477 ok(length == 1, "Expected 1, got %08x\n", length);
479 /* remove/add child and check what happens with collection */
480 hr = IXMLElement_removeChild(element, child);
481 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
484 hr = IXMLElementCollection_get_length(collection, &length);
485 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
486 ok(length == 0, "Expected 0, got %08x\n", length);
487 IXMLElementCollection_Release(collection);
489 hr = IXMLElement_AddRef(child);
490 ok(hr == 2, "Expected 2, got %08x\n", hr);
491 IXMLElement_Release(child);
492 hr = IXMLElement_addChild(element, child, 0, -1);
493 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
494 hr = IXMLElement_AddRef(child);
495 ok(hr == 2, "Expected 2, got %08x\n", hr);
496 IXMLElement_Release(child);
497 hr = IXMLElement_addChild(element, child2, 0, -1);
498 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
500 hr = IXMLElement_get_children(element, &collection);
501 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
502 ok(collection != NULL, "Expected non-NULL collection\n");
504 hr = IXMLElement_AddRef(child);
505 ok(hr == 2, "Expected 2, got %08x\n", hr);
506 IXMLElement_Release(child);
509 hr = IXMLElementCollection_get_length(collection, &length);
510 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
511 ok(length == 2, "Expected 2, got %08x\n", length);
513 IXMLElement_Release(child2);
516 hr = IXMLElementCollection_get_length(collection, &length);
517 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
518 ok(length == 2, "Expected 2, got %08x\n", length);
520 V_VT(&vIndex) = VT_I4;
522 hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child2);
523 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
524 ok(child2 != NULL, "Expected not NULL child\n");
525 IXMLElementCollection_Release(collection);
526 IXMLElement_Release(child2);
528 /* add element->child->child2 structure, then remove child2 from node */
529 V_VT(&vType) = VT_I4;
530 V_I4(&vType) = XMLELEMTYPE_TEXT;
531 V_VT(&vName) = VT_NULL;
532 hr = IXMLDocument_createElement(doc, vType, vName, &child2);
533 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
534 ok(child2 != NULL, "Expected non-NULL child\n");
536 hr = IXMLElement_addChild(child, child2, 0, -1);
537 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
539 hr = IXMLElement_removeChild(element, child2);
540 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
542 hr = IXMLElement_removeChild(child, child2);
543 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
545 hr = IXMLElement_removeChild(child, NULL);
546 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
548 IXMLElement_Release(element);
549 IXMLElement_Release(child);
550 IXMLElement_Release(child2);
551 IXMLDocument_Release(doc);
554 static BOOL test_try_xmldoc(void)
556 IXMLDocument *doc = NULL;
559 hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
560 &IID_IXMLDocument, (LPVOID*)&doc);
563 skip("Failed to create XMLDocument instance\n");
567 IXMLDocument_Release(doc);
575 hr = CoInitialize(NULL);
576 ok(hr == S_OK, "failed to init com\n");
578 if (!test_try_xmldoc())
585 test_xmlelem_collection();
586 test_xmlelem_children();