4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
34 const CLSID CLSID_DOMDocument2 = {0xf6d90f11, 0x9c73, 0x11d3, {0xb3, 0x2e, 0x00, 0xc0, 0x4f, 0x99, 0x0b, 0xb4}};
35 const IID IID_IXMLDOMDocument2 = {0x2933bf95, 0x7b36, 0x11d2, {0xb2, 0x0e, 0x00, 0xc0, 0x4f, 0x98, 0x3e, 0x60}};
37 static const WCHAR szEmpty[] = { 0 };
38 static const WCHAR szIncomplete[] = {
39 '<','?','x','m','l',' ',
40 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
42 static const WCHAR szComplete1[] = {
43 '<','?','x','m','l',' ',
44 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
45 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
47 static const WCHAR szComplete2[] = {
48 '<','?','x','m','l',' ',
49 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
50 '<','o','>','<','/','o','>','\n',0
52 static const WCHAR szComplete3[] = {
53 '<','?','x','m','l',' ',
54 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
55 '<','a','>','<','/','a','>','\n',0
57 static const WCHAR szComplete4[] = {
58 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
59 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
60 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
61 'f','n','1','.','t','x','t','\n',
62 '<','/','b','s','>','\n',
63 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
64 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
65 'f','n','2','.','t','x','t','\n',
66 '<','/','p','r','>','\n',
67 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
71 '<','/','b','a','>','\n',
72 '<','/','f','o','>','\n',
73 '<','/','l','c','>','\n',0
75 static const WCHAR szComplete5[] = {
76 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
77 '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','"',
78 ' ','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','"','>',
79 '<','S',':','s','c','o','p','e','>',
80 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
81 '<','/','S',':','s','c','o','p','e','>',
82 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
83 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
84 'c','o','m','p','u','t','e','r',
85 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
86 '<','/','S',':','s','e','a','r','c','h','>',0
89 static const CHAR szExampleXML[] =
90 "<?xml version='1.0' encoding='utf-8'?>\n"
91 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
96 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
97 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
98 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
106 " <c type=\"old\">C2 field</c>\n"
109 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
118 " <foo:c>C4 field</foo:c>\n"
122 static const WCHAR szNonExistentFile[] = {
123 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
125 static const WCHAR szDocument[] = {
126 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
129 static const WCHAR szOpen[] = { 'o','p','e','n',0 };
130 static WCHAR szdl[] = { 'd','l',0 };
131 static const WCHAR szvr[] = { 'v','r',0 };
132 static const WCHAR szlc[] = { 'l','c',0 };
133 static WCHAR szbs[] = { 'b','s',0 };
134 static const WCHAR szstr1[] = { 's','t','r','1',0 };
135 static const WCHAR szstr2[] = { 's','t','r','2',0 };
136 static const WCHAR szstar[] = { '*',0 };
137 static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0};
139 static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 };
140 static WCHAR szCommentXML[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
141 static WCHAR szCommentNodeText[] = {'#','c','o','m','m','e','n','t',0 };
143 static WCHAR szElement[] = {'E','l','e','T','e','s','t', 0 };
144 static WCHAR szElementXML[] = {'<','E','l','e','T','e','s','t','/','>',0 };
145 static WCHAR szElementXML2[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
146 static WCHAR szElementXML3[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
147 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
149 static WCHAR szAttribute[] = {'A','t','t','r',0 };
150 static WCHAR szAttributeXML[] = {'A','t','t','r','=','"','"',0 };
152 static WCHAR szCData[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
153 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
154 static WCHAR szCDataXML[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
155 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
157 static WCHAR szCDataNodeText[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
158 static WCHAR szDocFragmentText[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
160 static WCHAR szEntityRef[] = {'e','n','t','i','t','y','r','e','f',0 };
161 static WCHAR szEntityRefXML[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
163 #define expect_bstr_eq_and_free(bstr, expect) { \
164 BSTR bstrExp = alloc_str_from_narrow(expect); \
165 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
166 SysFreeString(bstr); \
167 SysFreeString(bstrExp); \
170 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
172 #define ole_check(expr) { \
174 ok(r == S_OK, #expr " returned %x\n", r); \
177 #define ole_expect(expr, expect) { \
179 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
182 static BSTR alloc_str_from_narrow(const char *str)
184 int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
185 BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
186 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
190 BSTR alloced_bstrs[256];
191 int alloced_bstrs_count = 0;
193 static BSTR _bstr_(const char *str)
195 assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
196 alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
197 return alloced_bstrs[alloced_bstrs_count++];
200 static void free_bstrs(void)
203 for (i = 0; i < alloced_bstrs_count; i++)
204 SysFreeString(alloced_bstrs[i]);
205 alloced_bstrs_count = 0;
208 static VARIANT _variantbstr_(const char *str)
212 V_BSTR(&v) = _bstr_(str);
216 static void get_str_for_type(DOMNodeType type, char *buf)
230 wsprintfA(buf, "[%d]", type);
234 static int get_node_position(IXMLDOMNode *node)
239 IXMLDOMNode_AddRef(node);
242 IXMLDOMNode *new_node;
245 r = IXMLDOMNode_get_previousSibling(node, &new_node);
246 ok(!FAILED(r), "get_previousSibling failed\n");
247 IXMLDOMNode_Release(node);
253 static void node_to_string(IXMLDOMNode *node, char *buf)
260 lstrcpyA(buf, "(null)");
264 IXMLDOMNode_AddRef(node);
267 IXMLDOMNode *new_node;
269 ole_check(IXMLDOMNode_get_nodeType(node, &type));
270 get_str_for_type(type, buf);
273 if (type == NODE_ATTRIBUTE)
276 ole_check(IXMLDOMNode_get_nodeName(node, &bstr));
278 wsprintfA(buf, "%ws", bstr);
283 r = IXMLDOMNode_selectSingleNode(node, _bstr_(".."), &new_node);
287 int pos = get_node_position(node);
288 DOMNodeType parent_type = NODE_INVALID;
289 r = IXMLDOMNode_get_parentNode(node, &new_node);
291 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
292 * results we "fix" it */
294 ole_check(IXMLDOMNode_get_nodeType(node, &parent_type));
295 /* we need also to workaround the no document node problem - see below */
296 if (((r == S_FALSE && type != NODE_DOCUMENT) || parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1)
298 todo_wine ok(FALSE, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
301 wsprintf(buf, "%d", pos);
305 ok(!FAILED(r), "get_parentNode failed (%08x)\n", r);
306 IXMLDOMNode_Release(node);
312 /* currently we can't access document node in wine. All our examples this is the
313 * root node so to be able to test query results we add it */
314 if (type != NODE_DOCUMENT)
316 todo_wine ok(FALSE, "Document node is not the last returned node!\n");
324 static char *list_to_string(IXMLDOMNodeList *list)
326 static char buf[4096];
333 lstrcpyA(buf, "(null)");
336 ole_check(IXMLDOMNodeList_get_length(list, &len));
337 for (i = 0; i < len; i++)
342 ole_check(IXMLDOMNodeList_nextNode(list, &node));
343 node_to_string(node, pos);
345 IXMLDOMNode_Release(node);
351 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, exptected %s\n", str, expstr); }
352 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, exptected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
354 static void test_domdoc( void )
357 IXMLDOMDocument *doc = NULL;
358 IXMLDOMParseError *error;
359 IXMLDOMElement *element = NULL;
361 IXMLDOMText *nodetext = NULL;
362 IXMLDOMComment *node_comment = NULL;
363 IXMLDOMAttribute *node_attr = NULL;
364 IXMLDOMNode *nodeChild = NULL;
365 IXMLDOMProcessingInstruction *nodePI = NULL;
372 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
373 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
377 /* try some stupid things */
378 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
379 ok( r == S_FALSE, "loadXML failed\n");
382 r = IXMLDOMDocument_loadXML( doc, NULL, &b );
383 ok( r == S_FALSE, "loadXML failed\n");
384 ok( b == VARIANT_FALSE, "failed to load XML string\n");
386 /* try to load a document from a nonexistent file */
388 str = SysAllocString( szNonExistentFile );
390 V_VT(&var) = VT_BSTR;
393 r = IXMLDOMDocument_load( doc, var, &b);
394 ok( r == S_FALSE, "load (from file) failed\n");
395 ok( b == VARIANT_FALSE, "failed to load XML file\n");
396 SysFreeString( str );
398 /* try load an empty document */
400 str = SysAllocString( szEmpty );
401 r = IXMLDOMDocument_loadXML( doc, str, &b );
402 ok( r == S_FALSE, "loadXML failed\n");
403 ok( b == VARIANT_FALSE, "failed to load XML string\n");
404 SysFreeString( str );
406 /* check that there's no document element */
408 r = IXMLDOMDocument_get_documentElement( doc, &element );
409 ok( r == S_FALSE, "should be no document element\n");
411 /* try finding a node */
413 str = SysAllocString( szstr1 );
414 r = IXMLDOMDocument_selectSingleNode( doc, str, &node );
415 ok( r == S_FALSE, "ret %08x\n", r );
416 SysFreeString( str );
419 str = SysAllocString( szIncomplete );
420 r = IXMLDOMDocument_loadXML( doc, str, &b );
421 ok( r == S_FALSE, "loadXML failed\n");
422 ok( b == VARIANT_FALSE, "failed to load XML string\n");
423 SysFreeString( str );
425 /* check that there's no document element */
426 element = (IXMLDOMElement*)1;
427 r = IXMLDOMDocument_get_documentElement( doc, &element );
428 ok( r == S_FALSE, "should be no document element\n");
429 ok( element == NULL, "Element should be NULL\n");
431 /* try to load something valid */
433 str = SysAllocString( szComplete1 );
434 r = IXMLDOMDocument_loadXML( doc, str, &b );
435 ok( r == S_OK, "loadXML failed\n");
436 ok( b == VARIANT_TRUE, "failed to load XML string\n");
437 SysFreeString( str );
439 /* try with a null out pointer */
440 r = IXMLDOMDocument_get_documentElement( doc, NULL );
441 ok( r == E_INVALIDARG, "should be no document element\n");
443 /* check if nodename is correct */
444 r = IXMLDOMDocument_get_nodeName( doc, NULL );
445 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
447 /* content doesn't matter here */
449 r = IXMLDOMDocument_get_nodeName( doc, &str );
450 ok ( r == S_OK, "get_nodeName wrong code\n");
451 ok ( str != NULL, "str is null\n");
452 ok( !lstrcmpW( str, szDocument ), "incorrect nodeName\n");
453 SysFreeString( str );
456 r = IXMLDOMDocument_put_text( doc, _bstr_("Should Fail") );
457 ok( r == E_FAIL, "ret %08x\n", r );
459 /* check that there's a document element */
461 r = IXMLDOMDocument_get_documentElement( doc, &element );
462 ok( r == S_OK, "should be a document element\n");
467 /* check if the tag is correct */
468 r = IXMLDOMElement_get_tagName( element, &tag );
469 ok( r == S_OK, "couldn't get tag name\n");
470 ok( tag != NULL, "tag was null\n");
471 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
472 SysFreeString( tag );
474 /* figure out what happens if we try to reload the document */
475 str = SysAllocString( szComplete2 );
476 r = IXMLDOMDocument_loadXML( doc, str, &b );
477 ok( r == S_OK, "loadXML failed\n");
478 ok( b == VARIANT_TRUE, "failed to load XML string\n");
479 SysFreeString( str );
481 /* check if the tag is still correct */
483 r = IXMLDOMElement_get_tagName( element, &tag );
484 ok( r == S_OK, "couldn't get tag name\n");
485 ok( tag != NULL, "tag was null\n");
486 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
487 SysFreeString( tag );
489 IXMLDOMElement_Release( element );
493 /* as soon as we call loadXML again, the document element will disappear */
495 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
496 ok( r == S_FALSE, "loadXML failed\n");
497 ok( b == 2, "variant modified\n");
498 r = IXMLDOMDocument_get_documentElement( doc, &element );
499 ok( r == S_FALSE, "should be no document element\n");
501 /* try to load something else simple and valid */
503 str = SysAllocString( szComplete3 );
504 r = IXMLDOMDocument_loadXML( doc, str, &b );
505 ok( r == S_OK, "loadXML failed\n");
506 ok( b == VARIANT_TRUE, "failed to load XML string\n");
507 SysFreeString( str );
509 /* try something a little more complicated */
511 str = SysAllocString( szComplete4 );
512 r = IXMLDOMDocument_loadXML( doc, str, &b );
513 ok( r == S_OK, "loadXML failed\n");
514 ok( b == VARIANT_TRUE, "failed to load XML string\n");
515 SysFreeString( str );
517 r = IXMLDOMDocument_get_parseError( doc, &error );
518 ok( r == S_OK, "returns %08x\n", r );
520 r = IXMLDOMParseError_get_errorCode( error, &code );
521 ok( r == S_FALSE, "returns %08x\n", r );
522 ok( code == 0, "code %ld\n", code );
523 IXMLDOMParseError_Release( error );
525 /* test createTextNode */
526 str = SysAllocString( szOpen );
527 r = IXMLDOMDocument_createTextNode(doc, str, NULL);
528 ok( r == E_INVALIDARG, "returns %08x\n", r );
529 r = IXMLDOMDocument_createTextNode(doc, str, &nodetext);
530 ok( r == S_OK, "returns %08x\n", r );
533 IXMLDOMNamedNodeMap *pAttribs;
535 /* Text Last Child Checks */
536 r = IXMLDOMText_get_lastChild(nodetext, NULL);
537 ok(r == E_INVALIDARG, "ret %08x\n", r );
539 nodeChild = (IXMLDOMNode*)0x1;
540 r = IXMLDOMText_get_lastChild(nodetext, &nodeChild);
541 ok(r == S_FALSE, "ret %08x\n", r );
542 ok(nodeChild == NULL, "nodeChild not NULL\n");
544 /* test get_attributes */
545 r = IXMLDOMText_get_attributes( nodetext, NULL );
546 ok( r == E_INVALIDARG, "get_attributes returned wrong code\n");
548 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
549 r = IXMLDOMText_get_attributes( nodetext, &pAttribs);
550 ok(r == S_FALSE, "ret %08x\n", r );
551 ok( pAttribs == NULL, "pAttribs not NULL\n");
553 /* test get_dataType */
554 r = IXMLDOMText_get_dataType(nodetext, &var);
555 ok(r == S_FALSE, "ret %08x\n", r );
556 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
559 /* test length property */
560 r = IXMLDOMText_get_length(nodetext, NULL);
561 ok(r == E_INVALIDARG, "ret %08x\n", r );
563 r = IXMLDOMText_get_length(nodetext, &nLength);
564 ok(r == S_OK, "ret %08x\n", r );
565 ok(nLength == 4, "expected 4 got %ld\n", nLength);
567 /* test nodeTypeString */
568 r = IXMLDOMText_get_nodeTypeString(nodetext, &str);
569 ok(r == S_OK, "ret %08x\n", r );
570 ok( !lstrcmpW( str, _bstr_("text") ), "incorrect nodeTypeString string\n");
574 r = IXMLDOMText_put_data(nodetext, _bstr_("This &is a ; test <>\\"));
575 ok(r == S_OK, "ret %08x\n", r );
578 r = IXMLDOMText_get_data(nodetext, &str);
579 ok(r == S_OK, "ret %08x\n", r );
580 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
583 /* Confirm XML text is good */
584 r = IXMLDOMText_get_xml(nodetext, &str);
585 ok(r == S_OK, "ret %08x\n", r );
586 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
589 /* Confirm we get the put_data Text back */
590 r = IXMLDOMText_get_text(nodetext, &str);
591 ok(r == S_OK, "ret %08x\n", r );
592 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
595 /* test substringData */
596 r = IXMLDOMText_substringData(nodetext, 0, 4, NULL);
597 ok(r == E_INVALIDARG, "ret %08x\n", r );
599 /* test substringData - Invalid offset */
600 str = (BSTR)&szElement;
601 r = IXMLDOMText_substringData(nodetext, -1, 4, &str);
602 ok(r == E_INVALIDARG, "ret %08x\n", r );
603 ok( str == NULL, "incorrect string\n");
605 /* test substringData - Invalid offset */
606 str = (BSTR)&szElement;
607 r = IXMLDOMText_substringData(nodetext, 30, 0, &str);
608 ok(r == S_FALSE, "ret %08x\n", r );
609 ok( str == NULL, "incorrect string\n");
611 /* test substringData - Invalid size */
612 str = (BSTR)&szElement;
613 r = IXMLDOMText_substringData(nodetext, 0, -1, &str);
614 ok(r == E_INVALIDARG, "ret %08x\n", r );
615 ok( str == NULL, "incorrect string\n");
617 /* test substringData - Invalid size */
618 str = (BSTR)&szElement;
619 r = IXMLDOMText_substringData(nodetext, 2, 0, &str);
620 ok(r == S_FALSE, "ret %08x\n", r );
621 ok( str == NULL, "incorrect string\n");
623 /* test substringData - Start of string */
624 r = IXMLDOMText_substringData(nodetext, 0, 4, &str);
625 ok(r == S_OK, "ret %08x\n", r );
626 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
629 /* test substringData - Middle of string */
630 r = IXMLDOMText_substringData(nodetext, 13, 4, &str);
631 ok(r == S_OK, "ret %08x\n", r );
632 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
635 /* test substringData - End of string */
636 r = IXMLDOMText_substringData(nodetext, 20, 4, &str);
637 ok(r == S_OK, "ret %08x\n", r );
638 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
641 /* test appendData */
642 r = IXMLDOMText_appendData(nodetext, NULL);
643 ok(r == S_OK, "ret %08x\n", r );
645 r = IXMLDOMText_appendData(nodetext, _bstr_(""));
646 ok(r == S_OK, "ret %08x\n", r );
648 r = IXMLDOMText_appendData(nodetext, _bstr_("Append"));
649 ok(r == S_OK, "ret %08x\n", r );
651 r = IXMLDOMText_get_text(nodetext, &str);
652 ok(r == S_OK, "ret %08x\n", r );
653 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
656 IXMLDOMText_Release( nodetext );
658 SysFreeString( str );
660 /* test Create Comment */
661 r = IXMLDOMDocument_createComment(doc, NULL, NULL);
662 ok( r == E_INVALIDARG, "returns %08x\n", r );
663 r = IXMLDOMDocument_createComment(doc, szComment, &node_comment);
664 ok( r == S_OK, "returns %08x\n", r );
667 /* Last Child Checks */
668 r = IXMLDOMComment_get_lastChild(node_comment, NULL);
669 ok(r == E_INVALIDARG, "ret %08x\n", r );
671 nodeChild = (IXMLDOMNode*)0x1;
672 r = IXMLDOMComment_get_lastChild(node_comment, &nodeChild);
673 ok(r == S_FALSE, "ret %08x\n", r );
674 ok(nodeChild == NULL, "pLastChild not NULL\n");
676 IXMLDOMComment_Release( node_comment );
679 /* test Create Attribute */
680 r = IXMLDOMDocument_createAttribute(doc, NULL, NULL);
681 ok( r == E_INVALIDARG, "returns %08x\n", r );
682 r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr);
683 ok( r == S_OK, "returns %08x\n", r );
684 IXMLDOMText_Release( node_attr);
686 /* test Processing Instruction */
687 str = SysAllocStringLen(NULL, 0);
688 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, NULL);
689 ok( r == E_INVALIDARG, "returns %08x\n", r );
690 r = IXMLDOMDocument_createProcessingInstruction(doc, NULL, str, &nodePI);
691 ok( r == E_FAIL, "returns %08x\n", r );
692 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, &nodePI);
693 ok( r == E_FAIL, "returns %08x\n", r );
696 r = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI);
697 ok( r == S_OK, "returns %08x\n", r );
700 /* Last Child Checks */
701 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, NULL);
702 ok(r == E_INVALIDARG, "ret %08x\n", r );
704 nodeChild = (IXMLDOMNode*)0x1;
705 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, &nodeChild);
706 ok(r == S_FALSE, "ret %08x\n", r );
707 ok(nodeChild == NULL, "nodeChild not NULL\n");
709 r = IXMLDOMProcessingInstruction_get_dataType(nodePI, &var);
710 ok(r == S_FALSE, "ret %08x\n", r );
711 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
715 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
716 ok(r == S_OK, "ret %08x\n", r );
717 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
721 r = IXMLDOMProcessingInstruction_get_target(nodePI, &str);
722 ok(r == S_OK, "ret %08x\n", r );
723 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect target string\n");
726 /* test nodeTypeString */
727 r = IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI, &str);
728 ok(r == S_OK, "ret %08x\n", r );
729 ok( !lstrcmpW( str, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
732 /* test get_nodeValue */
733 r = IXMLDOMProcessingInstruction_get_nodeValue(nodePI, &var);
734 ok(r == S_OK, "ret %08x\n", r );
735 ok( !lstrcmpW( V_BSTR(&var), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
739 r = IXMLDOMProcessingInstruction_get_data(nodePI, &str);
740 ok(r == S_OK, "ret %08x\n", r );
741 ok( !lstrcmpW( str, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
745 r = IXMLDOMProcessingInstruction_put_data(nodePI, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
746 ok(r == E_FAIL, "ret %08x\n", r );
748 /* test get nodeName */
749 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
750 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
751 ok(r == S_OK, "ret %08x\n", r );
754 IXMLDOMProcessingInstruction_Release(nodePI);
757 r = IXMLDOMDocument_Release( doc );
758 ok( r == 0, "document ref count incorrect\n");
763 static void test_domnode( void )
766 IXMLDOMDocument *doc = NULL, *owner = NULL;
767 IXMLDOMElement *element = NULL;
768 IXMLDOMNamedNodeMap *map = NULL;
769 IXMLDOMNode *node = NULL, *next = NULL;
770 IXMLDOMNodeList *list = NULL;
771 DOMNodeType type = NODE_INVALID;
777 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
778 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
783 str = SysAllocString( szComplete4 );
784 r = IXMLDOMDocument_loadXML( doc, str, &b );
785 ok( r == S_OK, "loadXML failed\n");
786 ok( b == VARIANT_TRUE, "failed to load XML string\n");
787 SysFreeString( str );
792 r = IXMLDOMNode_hasChildNodes( doc, &b );
793 ok( r == S_OK, "hasChildNoes bad return\n");
794 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
796 r = IXMLDOMDocument_get_documentElement( doc, &element );
797 ok( r == S_OK, "should be a document element\n");
798 ok( element != NULL, "should be an element\n");
801 ok( FALSE, "no document\n");
804 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
806 r = IXMLDOMNode_get_nodeValue( doc, NULL );
807 ok(r == E_INVALIDARG, "get_nodeValue ret %08x\n", r );
809 r = IXMLDOMNode_get_nodeValue( doc, &var );
810 ok( r == S_FALSE, "nextNode returned wrong code\n");
811 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
812 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
817 r = IXMLDOMNode_get_ownerDocument( element, &owner );
819 ok( r == S_OK, "get_ownerDocument return code\n");
821 ok( owner != doc, "get_ownerDocument return\n");
824 r = IXMLDOMNode_get_nodeType( element, &type);
825 ok( r == S_OK, "getNamedItem returned wrong code\n");
826 ok( type == NODE_ELEMENT, "node not an element\n");
829 r = IXMLDOMNode_get_baseName( element, &str );
830 ok( r == S_OK, "get_baseName returned wrong code\n");
831 ok( lstrcmpW(str,szlc) == 0, "basename was wrong\n");
834 /* check if nodename is correct */
835 r = IXMLDOMElement_get_nodeName( element, NULL );
836 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
838 /* content doesn't matter here */
840 r = IXMLDOMElement_get_nodeName( element, &str );
841 ok ( r == S_OK, "get_nodeName wrong code\n");
842 ok ( str != NULL, "str is null\n");
843 ok( !lstrcmpW( str, szlc ), "incorrect nodeName\n");
844 SysFreeString( str );
846 str = SysAllocString( szNonExistentFile );
849 r = IXMLDOMElement_getAttribute( element, str, &var );
850 ok( r == E_FAIL, "getAttribute ret %08x\n", r );
851 ok( V_VT(&var) == VT_NULL, "vt = %x\n", V_VT(&var));
853 SysFreeString( str );
855 str = SysAllocString( szdl );
858 r = IXMLDOMElement_getAttribute( element, str, &var );
859 ok( r == S_OK, "getAttribute ret %08x\n", r );
860 ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
861 ok( !lstrcmpW(V_BSTR(&var), szstr1), "wrong attr value\n");
862 VariantClear( &var );
864 r = IXMLDOMElement_getAttribute( element, NULL, &var );
865 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
867 r = IXMLDOMElement_getAttribute( element, str, NULL );
868 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
870 SysFreeString( str );
872 r = IXMLDOMElement_get_attributes( element, &map );
873 ok( r == S_OK, "get_attributes returned wrong code\n");
874 ok( map != NULL, "should be attributes\n");
877 r = IXMLDOMNode_hasChildNodes( element, &b );
878 ok( r == S_OK, "hasChildNoes bad return\n");
879 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
882 ok( FALSE, "no element\n");
886 ISupportErrorInfo *support_error;
887 r = IXMLDOMNamedNodeMap_QueryInterface( map, &IID_ISupportErrorInfo, (LPVOID*)&support_error );
888 ok( r == S_OK, "ret %08x\n", r );
890 r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMNamedNodeMap );
893 ok( r == S_OK, "ret %08x\n", r );
895 ISupportErrorInfo_Release( support_error );
897 str = SysAllocString( szdl );
898 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
899 ok( r == S_OK, "getNamedItem returned wrong code\n");
900 ok( node != NULL, "should be attributes\n");
901 IXMLDOMNode_Release(node);
902 SysFreeString( str );
904 str = SysAllocString( szdl );
905 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, NULL );
906 ok( r == E_INVALIDARG, "getNamedItem should return E_INVALIDARG\n");
907 SysFreeString( str );
909 /* something that isn't in szComplete4 */
910 str = SysAllocString( szOpen );
911 node = (IXMLDOMNode *) 1;
912 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
913 ok( r = S_FALSE, "getNamedItem found a node that wasn't there\n");
914 ok( node == NULL, "getNamedItem should have returned NULL\n");
915 SysFreeString( str );
917 /* test indexed access of attributes */
918 r = IXMLDOMNamedNodeMap_get_length( map, &count );
919 ok ( r == S_OK, "get_length wrong code\n");
920 ok ( count == 1, "get_length != 1\n");
923 r = IXMLDOMNamedNodeMap_get_item( map, -1, &node);
924 ok ( r == S_FALSE, "get_item (-1) wrong code\n");
925 ok ( node == NULL, "there is no node\n");
928 r = IXMLDOMNamedNodeMap_get_item( map, 1, &node);
929 ok ( r == S_FALSE, "get_item (1) wrong code\n");
930 ok ( node == NULL, "there is no attribute\n");
933 r = IXMLDOMNamedNodeMap_get_item( map, 0, &node);
934 ok ( r == S_OK, "get_item (0) wrong code\n");
935 ok ( node != NULL, "should be attribute\n");
937 r = IXMLDOMNode_get_nodeName( node, NULL );
938 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
940 /* content doesn't matter here */
942 r = IXMLDOMNode_get_nodeName( node, &str );
943 ok ( r == S_OK, "get_nodeName wrong code\n");
944 ok ( str != NULL, "str is null\n");
945 ok( !lstrcmpW( str, szdl ), "incorrect node name\n");
946 SysFreeString( str );
948 /* test sequential access of attributes */
950 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
951 ok ( r == S_OK, "nextNode (first time) wrong code\n");
952 ok ( node != NULL, "nextNode, should be attribute\n");
954 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
955 ok ( r != S_OK, "nextNode (second time) wrong code\n");
956 ok ( node == NULL, "nextNode, there is no attribute\n");
958 r = IXMLDOMNamedNodeMap_reset( map );
959 ok ( r == S_OK, "reset should return S_OK\n");
961 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
962 ok ( r == S_OK, "nextNode (third time) wrong code\n");
963 ok ( node != NULL, "nextNode, should be attribute\n");
966 ok( FALSE, "no map\n");
971 r = IXMLDOMNode_get_nodeType( node, &type);
972 ok( r == S_OK, "getNamedItem returned wrong code\n");
973 ok( type == NODE_ATTRIBUTE, "node not an attribute\n");
976 r = IXMLDOMNode_get_baseName( node, NULL );
977 ok( r == E_INVALIDARG, "get_baseName returned wrong code\n");
980 r = IXMLDOMNode_get_baseName( node, &str );
981 ok( r == S_OK, "get_baseName returned wrong code\n");
982 ok( lstrcmpW(str,szdl) == 0, "basename was wrong\n");
983 SysFreeString( str );
985 r = IXMLDOMNode_get_nodeValue( node, &var );
986 ok( r == S_OK, "returns %08x\n", r );
987 ok( V_VT(&var) == VT_BSTR, "vt %x\n", V_VT(&var));
988 ok( !lstrcmpW(V_BSTR(&var), szstr1), "nodeValue incorrect\n");
991 r = IXMLDOMNode_get_childNodes( node, NULL );
992 ok( r == E_INVALIDARG, "get_childNodes returned wrong code\n");
994 r = IXMLDOMNode_get_childNodes( node, &list );
995 ok( r == S_OK, "get_childNodes returned wrong code\n");
999 r = IXMLDOMNodeList_nextNode( list, &next );
1000 ok( r == S_OK, "nextNode returned wrong code\n");
1003 ok( FALSE, "no childlist\n");
1008 r = IXMLDOMNode_hasChildNodes( next, &b );
1009 ok( r == S_FALSE, "hasChildNoes bad return\n");
1010 ok( b == VARIANT_FALSE, "hasChildNoes wrong result\n");
1012 type = NODE_INVALID;
1013 r = IXMLDOMNode_get_nodeType( next, &type);
1014 ok( r == S_OK, "getNamedItem returned wrong code\n");
1015 ok( type == NODE_TEXT, "node not text\n");
1018 r = IXMLDOMNode_get_baseName( next, &str );
1019 ok( r == S_FALSE, "get_baseName returned wrong code\n");
1020 ok( str == NULL, "basename was wrong\n");
1024 ok( FALSE, "no next\n");
1027 IXMLDOMNode_Release( next );
1030 IXMLDOMNodeList_Release( list );
1033 IXMLDOMNode_Release( node );
1036 ok( FALSE, "no node\n");
1040 IXMLDOMNamedNodeMap_Release( map );
1042 /* now traverse the tree from the root element */
1046 r = IXMLDOMNode_get_childNodes( element, &list );
1047 ok( r == S_OK, "get_childNodes returned wrong code\n");
1049 /* using get_item for child list doesn't advance the position */
1050 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
1051 expect_node(node, "E2.E2.D1");
1052 IXMLDOMNode_Release(node);
1053 ole_check(IXMLDOMNodeList_nextNode(list, &node));
1054 expect_node(node, "E1.E2.D1");
1055 IXMLDOMNode_Release(node);
1056 ole_check(IXMLDOMNodeList_reset(list));
1058 IXMLDOMNodeList_AddRef(list);
1059 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1060 ole_check(IXMLDOMNodeList_reset(list));
1063 ok( FALSE, "no element\n");
1065 node = (void*)0xdeadbeef;
1066 r = IXMLDOMNode_selectSingleNode( element, szdl, &node );
1067 ok( r == S_FALSE, "ret %08x\n", r );
1068 ok( node == NULL, "node %p\n", node );
1069 r = IXMLDOMNode_selectSingleNode( element, szbs, &node );
1070 ok( r == S_OK, "ret %08x\n", r );
1071 r = IXMLDOMNode_Release( node );
1072 ok( r == 0, "ret %08x\n", r );
1076 r = IXMLDOMNodeList_get_length( list, &count );
1077 ok( r == S_OK, "get_length returns %08x\n", r );
1078 ok( count == 4, "get_length got %ld\n", count );
1080 r = IXMLDOMNodeList_nextNode( list, &node );
1081 ok( r == S_OK, "nextNode returned wrong code\n");
1084 ok( FALSE, "no list\n");
1088 type = NODE_INVALID;
1089 r = IXMLDOMNode_get_nodeType( node, &type);
1090 ok( r == S_OK, "getNamedItem returned wrong code\n");
1091 ok( type == NODE_ELEMENT, "node not text\n");
1094 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
1095 r = IXMLDOMNode_get_nodeValue( node, &var );
1096 ok( r == S_FALSE, "nextNode returned wrong code\n");
1097 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
1098 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
1100 r = IXMLDOMNode_hasChildNodes( node, NULL );
1101 ok( r == E_INVALIDARG, "hasChildNoes bad return\n");
1104 r = IXMLDOMNode_hasChildNodes( node, &b );
1105 ok( r == S_OK, "hasChildNoes bad return\n");
1106 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1109 r = IXMLDOMNode_get_baseName( node, &str );
1110 ok( r == S_OK, "get_baseName returned wrong code\n");
1111 ok( lstrcmpW(str,szbs) == 0, "basename was wrong\n");
1115 ok( FALSE, "no node\n");
1118 IXMLDOMNode_Release( node );
1120 IXMLDOMNodeList_Release( list );
1122 IXMLDOMElement_Release( element );
1125 str = SysAllocString( szComplete5 );
1126 r = IXMLDOMDocument_loadXML( doc, str, &b );
1127 ok( r == S_OK, "loadXML failed\n");
1128 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1129 SysFreeString( str );
1132 r = IXMLDOMNode_hasChildNodes( doc, &b );
1133 ok( r == S_OK, "hasChildNoes bad return\n");
1134 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1136 r = IXMLDOMDocument_get_documentElement( doc, &element );
1137 ok( r == S_OK, "should be a document element\n");
1138 ok( element != NULL, "should be an element\n");
1142 static const WCHAR szSSearch[] = {'S',':','s','e','a','r','c','h',0};
1145 /* check if the tag is correct */
1146 r = IXMLDOMElement_get_tagName( element, &tag );
1147 ok( r == S_OK, "couldn't get tag name\n");
1148 ok( tag != NULL, "tag was null\n");
1149 ok( !lstrcmpW( tag, szSSearch ), "incorrect tag name\n");
1150 SysFreeString( tag );
1154 IXMLDOMElement_Release( element );
1156 IXMLDOMDocument_Release( doc );
1159 static void test_refs(void)
1164 IXMLDOMDocument *doc = NULL;
1165 IXMLDOMElement *element = NULL;
1166 IXMLDOMNode *node = NULL, *node2;
1167 IXMLDOMNodeList *node_list = NULL;
1169 IUnknown *unk, *unk2;
1171 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1172 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1175 ref = IXMLDOMDocument_Release(doc);
1176 ok( ref == 0, "ref %d\n", ref);
1178 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1179 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1183 str = SysAllocString( szComplete4 );
1184 r = IXMLDOMDocument_loadXML( doc, str, &b );
1185 ok( r == S_OK, "loadXML failed\n");
1186 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1187 SysFreeString( str );
1189 ref = IXMLDOMDocument_AddRef( doc );
1190 ok( ref == 2, "ref %d\n", ref );
1191 ref = IXMLDOMDocument_AddRef( doc );
1192 ok( ref == 3, "ref %d\n", ref );
1193 IXMLDOMDocument_Release( doc );
1194 IXMLDOMDocument_Release( doc );
1196 r = IXMLDOMDocument_get_documentElement( doc, &element );
1197 ok( r == S_OK, "should be a document element\n");
1198 ok( element != NULL, "should be an element\n");
1200 ref = IXMLDOMDocument_AddRef( doc );
1201 ok( ref == 2, "ref %d\n", ref );
1202 IXMLDOMDocument_Release( doc );
1204 r = IXMLDOMElement_get_childNodes( element, &node_list );
1205 ok( r == S_OK, "rets %08x\n", r);
1206 ref = IXMLDOMNodeList_AddRef( node_list );
1207 ok( ref == 2, "ref %d\n", ref );
1208 IXMLDOMNodeList_Release( node_list );
1210 IXMLDOMNodeList_get_item( node_list, 0, &node );
1211 ok( r == S_OK, "rets %08x\n", r);
1213 IXMLDOMNodeList_get_item( node_list, 0, &node2 );
1214 ok( r == S_OK, "rets %08x\n", r);
1216 ref = IXMLDOMNode_AddRef( node );
1217 ok( ref == 2, "ref %d\n", ref );
1218 IXMLDOMNode_Release( node );
1220 ref = IXMLDOMNode_Release( node );
1221 ok( ref == 0, "ref %d\n", ref );
1222 ref = IXMLDOMNode_Release( node2 );
1223 ok( ref == 0, "ref %d\n", ref );
1225 ref = IXMLDOMNodeList_Release( node_list );
1226 ok( ref == 0, "ref %d\n", ref );
1228 ok( node != node2, "node %p node2 %p\n", node, node2 );
1230 ref = IXMLDOMDocument_Release( doc );
1231 ok( ref == 0, "ref %d\n", ref );
1233 ref = IXMLDOMElement_AddRef( element );
1235 ok( ref == 3, "ref %d\n", ref );
1237 IXMLDOMElement_Release( element );
1239 /* IUnknown must be unique however we obtain it */
1240 r = IXMLDOMElement_QueryInterface( element, &IID_IUnknown, (LPVOID*)&unk );
1241 ok( r == S_OK, "rets %08x\n", r );
1242 r = IXMLDOMElement_QueryInterface( element, &IID_IXMLDOMNode, (LPVOID*)&node );
1243 ok( r == S_OK, "rets %08x\n", r );
1244 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk2 );
1245 ok( r == S_OK, "rets %08x\n", r );
1246 ok( unk == unk2, "unk %p unk2 %p\n", unk, unk2 );
1248 IUnknown_Release( unk2 );
1249 IUnknown_Release( unk );
1250 IXMLDOMNode_Release( node );
1252 IXMLDOMElement_Release( element );
1256 static void test_create(void)
1261 IXMLDOMDocument *doc;
1262 IXMLDOMElement *element;
1263 IXMLDOMNode *root, *node, *child;
1264 IXMLDOMNamedNodeMap *attr_map;
1269 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1270 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1275 V_I4(&var) = NODE_ELEMENT;
1276 str = SysAllocString( szlc );
1277 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1278 ok( r == S_OK, "returns %08x\n", r );
1279 r = IXMLDOMDocument_appendChild( doc, node, &root );
1280 ok( r == S_OK, "returns %08x\n", r );
1281 ok( node == root, "%p %p\n", node, root );
1283 ref = IXMLDOMNode_AddRef( node );
1284 ok(ref == 3, "ref %d\n", ref);
1285 IXMLDOMNode_Release( node );
1287 ref = IXMLDOMNode_Release( node );
1288 ok(ref == 1, "ref %d\n", ref);
1289 SysFreeString( str );
1292 V_I4(&var) = NODE_ELEMENT;
1293 str = SysAllocString( szbs );
1294 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1295 ok( r == S_OK, "returns %08x\n", r );
1297 ref = IXMLDOMNode_AddRef( node );
1298 ok(ref == 2, "ref = %d\n", ref);
1299 IXMLDOMNode_Release( node );
1301 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk );
1302 ok( r == S_OK, "returns %08x\n", r );
1304 ref = IXMLDOMNode_AddRef( unk );
1305 ok(ref == 3, "ref = %d\n", ref);
1306 IXMLDOMNode_Release( unk );
1308 V_VT(&var) = VT_EMPTY;
1309 r = IXMLDOMNode_insertBefore( root, (IXMLDOMNode*)unk, var, &child );
1310 ok( r == S_OK, "returns %08x\n", r );
1311 ok( unk == (IUnknown*)child, "%p %p\n", unk, child );
1312 IXMLDOMNode_Release( child );
1313 IUnknown_Release( unk );
1316 V_VT(&var) = VT_NULL;
1317 V_DISPATCH(&var) = (IDispatch*)node;
1318 r = IXMLDOMNode_insertBefore( root, node, var, &child );
1319 ok( r == S_OK, "returns %08x\n", r );
1320 ok( node == child, "%p %p\n", node, child );
1321 IXMLDOMNode_Release( child );
1324 V_VT(&var) = VT_NULL;
1325 V_DISPATCH(&var) = (IDispatch*)node;
1326 r = IXMLDOMNode_insertBefore( root, node, var, NULL );
1327 ok( r == S_OK, "returns %08x\n", r );
1328 IXMLDOMNode_Release( node );
1330 r = IXMLDOMNode_QueryInterface( root, &IID_IXMLDOMElement, (LPVOID*)&element );
1331 ok( r == S_OK, "returns %08x\n", r );
1333 r = IXMLDOMElement_get_attributes( element, &attr_map );
1334 ok( r == S_OK, "returns %08x\n", r );
1335 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1336 ok( r == S_OK, "returns %08x\n", r );
1337 ok( num == 0, "num %ld\n", num );
1338 IXMLDOMNamedNodeMap_Release( attr_map );
1340 V_VT(&var) = VT_BSTR;
1341 V_BSTR(&var) = SysAllocString( szstr1 );
1342 name = SysAllocString( szdl );
1343 r = IXMLDOMElement_setAttribute( element, name, var );
1344 ok( r == S_OK, "returns %08x\n", r );
1345 r = IXMLDOMElement_get_attributes( element, &attr_map );
1346 ok( r == S_OK, "returns %08x\n", r );
1347 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1348 ok( r == S_OK, "returns %08x\n", r );
1349 ok( num == 1, "num %ld\n", num );
1350 IXMLDOMNamedNodeMap_Release( attr_map );
1353 V_VT(&var) = VT_BSTR;
1354 V_BSTR(&var) = SysAllocString( szstr2 );
1355 r = IXMLDOMElement_setAttribute( element, name, var );
1356 ok( r == S_OK, "returns %08x\n", r );
1357 r = IXMLDOMElement_get_attributes( element, &attr_map );
1358 ok( r == S_OK, "returns %08x\n", r );
1359 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1360 ok( r == S_OK, "returns %08x\n", r );
1361 ok( num == 1, "num %ld\n", num );
1362 IXMLDOMNamedNodeMap_Release( attr_map );
1364 r = IXMLDOMElement_getAttribute( element, name, &var );
1365 ok( r == S_OK, "returns %08x\n", r );
1366 ok( !lstrcmpW(V_BSTR(&var), szstr2), "wrong attr value\n");
1368 SysFreeString(name);
1370 V_VT(&var) = VT_BSTR;
1371 V_BSTR(&var) = SysAllocString( szstr1 );
1372 name = SysAllocString( szlc );
1373 r = IXMLDOMElement_setAttribute( element, name, var );
1374 ok( r == S_OK, "returns %08x\n", r );
1375 r = IXMLDOMElement_get_attributes( element, &attr_map );
1376 ok( r == S_OK, "returns %08x\n", r );
1377 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1378 ok( r == S_OK, "returns %08x\n", r );
1379 ok( num == 2, "num %ld\n", num );
1380 IXMLDOMNamedNodeMap_Release( attr_map );
1382 SysFreeString(name);
1386 name = SysAllocString( szbs );
1387 r = IXMLDOMElement_setAttribute( element, name, var );
1388 ok( r == S_OK, "returns %08x\n", r );
1390 r = IXMLDOMElement_getAttribute( element, name, &var );
1391 ok( r == S_OK, "returns %08x\n", r );
1392 ok( V_VT(&var) == VT_BSTR, "variant type %x\n", V_VT(&var));
1394 SysFreeString(name);
1396 IXMLDOMElement_Release( element );
1397 IXMLDOMNode_Release( root );
1398 IXMLDOMDocument_Release( doc );
1401 static void test_getElementsByTagName(void)
1406 IXMLDOMDocument *doc;
1407 IXMLDOMNodeList *node_list;
1410 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1411 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1415 str = SysAllocString( szComplete4 );
1416 r = IXMLDOMDocument_loadXML( doc, str, &b );
1417 ok( r == S_OK, "loadXML failed\n");
1418 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1419 SysFreeString( str );
1421 str = SysAllocString( szstar );
1422 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1423 ok( r == S_OK, "ret %08x\n", r );
1424 r = IXMLDOMNodeList_get_length( node_list, &len );
1425 ok( r == S_OK, "ret %08x\n", r );
1426 ok( len == 6, "len %ld\n", len );
1427 IXMLDOMNodeList_Release( node_list );
1428 SysFreeString( str );
1430 str = SysAllocString( szbs );
1431 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1432 ok( r == S_OK, "ret %08x\n", r );
1433 r = IXMLDOMNodeList_get_length( node_list, &len );
1434 ok( r == S_OK, "ret %08x\n", r );
1435 ok( len == 1, "len %ld\n", len );
1436 IXMLDOMNodeList_Release( node_list );
1437 SysFreeString( str );
1439 str = SysAllocString( szdl );
1440 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1441 ok( r == S_OK, "ret %08x\n", r );
1442 r = IXMLDOMNodeList_get_length( node_list, &len );
1443 ok( r == S_OK, "ret %08x\n", r );
1444 ok( len == 0, "len %ld\n", len );
1445 IXMLDOMNodeList_Release( node_list );
1446 SysFreeString( str );
1448 str = SysAllocString( szstr1 );
1449 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1450 ok( r == S_OK, "ret %08x\n", r );
1451 r = IXMLDOMNodeList_get_length( node_list, &len );
1452 ok( r == S_OK, "ret %08x\n", r );
1453 ok( len == 0, "len %ld\n", len );
1454 IXMLDOMNodeList_Release( node_list );
1455 SysFreeString( str );
1457 IXMLDOMDocument_Release( doc );
1460 static void test_get_text(void)
1465 IXMLDOMDocument *doc;
1466 IXMLDOMNode *node, *node2, *node3;
1467 IXMLDOMNodeList *node_list;
1468 IXMLDOMNamedNodeMap *node_map;
1470 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1471 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1475 str = SysAllocString( szComplete4 );
1476 r = IXMLDOMDocument_loadXML( doc, str, &b );
1477 ok( r == S_OK, "loadXML failed\n");
1478 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1479 SysFreeString( str );
1481 str = SysAllocString( szbs );
1482 r = IXMLDOMDocument_getElementsByTagName( doc, str, &node_list );
1483 ok( r == S_OK, "ret %08x\n", r );
1486 r = IXMLDOMNodeList_get_item( node_list, 0, &node );
1487 ok( r == S_OK, "ret %08x\n", r );
1488 IXMLDOMNodeList_Release( node_list );
1490 /* Invalid output parameter*/
1491 r = IXMLDOMNode_get_text( node, NULL );
1492 ok( r == E_INVALIDARG, "ret %08x\n", r );
1494 r = IXMLDOMNode_get_text( node, &str );
1495 ok( r == S_OK, "ret %08x\n", r );
1497 ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)), "wrong string\n" );
1499 ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)-4), "wrong string\n" );
1502 r = IXMLDOMNode_get_attributes( node, &node_map );
1503 ok( r == S_OK, "ret %08x\n", r );
1505 str = SysAllocString( szvr );
1506 r = IXMLDOMNamedNodeMap_getNamedItem( node_map, str, &node2 );
1507 ok( r == S_OK, "ret %08x\n", r );
1510 r = IXMLDOMNode_get_text( node2, &str );
1511 ok( r == S_OK, "ret %08x\n", r );
1512 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1515 r = IXMLDOMNode_get_firstChild( node2, &node3 );
1516 ok( r == S_OK, "ret %08x\n", r );
1518 r = IXMLDOMNode_get_text( node3, &str );
1519 ok( r == S_OK, "ret %08x\n", r );
1520 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1524 IXMLDOMNode_Release( node3 );
1525 IXMLDOMNode_Release( node2 );
1526 IXMLDOMNamedNodeMap_Release( node_map );
1527 IXMLDOMNode_Release( node );
1528 IXMLDOMDocument_Release( doc );
1531 static void test_get_childNodes(void)
1536 IXMLDOMDocument *doc;
1537 IXMLDOMElement *element;
1538 IXMLDOMNode *node, *node2;
1539 IXMLDOMNodeList *node_list, *node_list2;
1542 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1543 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1547 str = SysAllocString( szComplete4 );
1548 r = IXMLDOMDocument_loadXML( doc, str, &b );
1549 ok( r == S_OK, "loadXML failed\n");
1550 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1551 SysFreeString( str );
1553 r = IXMLDOMDocument_get_documentElement( doc, &element );
1554 ok( r == S_OK, "ret %08x\n", r);
1556 r = IXMLDOMElement_get_childNodes( element, &node_list );
1557 ok( r == S_OK, "ret %08x\n", r);
1559 r = IXMLDOMNodeList_get_length( node_list, &len );
1560 ok( r == S_OK, "ret %08x\n", r);
1561 ok( len == 4, "len %ld\n", len);
1563 r = IXMLDOMNodeList_get_item( node_list, 2, &node );
1564 ok( r == S_OK, "ret %08x\n", r);
1566 r = IXMLDOMNode_get_childNodes( node, &node_list2 );
1567 ok( r == S_OK, "ret %08x\n", r);
1569 r = IXMLDOMNodeList_get_length( node_list2, &len );
1570 ok( r == S_OK, "ret %08x\n", r);
1571 ok( len == 0, "len %ld\n", len);
1573 r = IXMLDOMNodeList_get_item( node_list2, 0, &node2);
1574 ok( r == S_FALSE, "ret %08x\n", r);
1576 IXMLDOMNodeList_Release( node_list2 );
1577 IXMLDOMNode_Release( node );
1578 IXMLDOMNodeList_Release( node_list );
1579 IXMLDOMElement_Release( element );
1580 IXMLDOMDocument_Release( doc );
1583 static void test_removeChild(void)
1588 IXMLDOMDocument *doc;
1589 IXMLDOMElement *element;
1590 IXMLDOMNode *node, *node2, *node3, *node4;
1591 IXMLDOMNodeList *node_list, *node_list2;
1593 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1594 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1598 str = SysAllocString( szComplete4 );
1599 r = IXMLDOMDocument_loadXML( doc, str, &b );
1600 ok( r == S_OK, "loadXML failed\n");
1601 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1602 SysFreeString( str );
1604 r = IXMLDOMDocument_get_documentElement( doc, &element );
1605 ok( r == S_OK, "ret %08x\n", r);
1607 r = IXMLDOMElement_get_childNodes( element, &node_list );
1608 ok( r == S_OK, "ret %08x\n", r);
1610 r = IXMLDOMNodeList_get_item( node_list, 3, &node );
1611 ok( r == S_OK, "ret %08x\n", r);
1613 r = IXMLDOMNode_get_childNodes( node, &node_list2 );
1614 ok( r == S_OK, "ret %08x\n", r);
1616 r = IXMLDOMNodeList_get_item( node_list, 0, &node4 );
1617 ok( r == S_OK, "ret %08x\n", r);
1619 r = IXMLDOMElement_removeChild( element, NULL, &node2 );
1620 ok( r == E_INVALIDARG, "ret %08x\n", r );
1622 r = IXMLDOMElement_removeChild( element, node4, &node2 );
1623 ok( r == S_OK, "ret %08x\n", r);
1624 ok( node4 == node2, "node %p node2 %p\n", node4, node2 );
1626 r = IXMLDOMNode_get_parentNode( node4, &node3 );
1627 ok( r == S_FALSE, "ret %08x\n", r);
1628 ok( node3 == NULL, "%p\n", node3 );
1630 IXMLDOMNode_Release( node2 );
1631 IXMLDOMNode_Release( node4 );
1632 IXMLDOMNodeList_Release( node_list2 );
1633 IXMLDOMNode_Release( node );
1634 IXMLDOMNodeList_Release( node_list );
1635 IXMLDOMElement_Release( element );
1636 IXMLDOMDocument_Release( doc );
1639 static void test_XMLHTTP(void)
1641 static const WCHAR wszBody[] = {'m','o','d','e','=','T','e','s','t',0};
1642 static WCHAR wszPOST[] = {'P','O','S','T',0};
1643 static WCHAR wszUrl[] = {'h','t','t','p',':','/','/',
1644 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
1645 'p','o','s','t','t','e','s','t','.','p','h','p',0};
1646 static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
1647 IXMLHttpRequest *pXMLHttpRequest;
1652 HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
1653 CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
1654 (void **)&pXMLHttpRequest);
1656 ok(hr == S_OK, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr);
1661 VariantInit(&dummy);
1662 V_VT(&dummy) = VT_ERROR;
1663 V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
1664 VariantInit(&varfalse);
1665 V_VT(&varfalse) = VT_BOOL;
1666 V_BOOL(&varfalse) = VARIANT_FALSE;
1667 V_VT(&varbody) = VT_BSTR;
1668 V_BSTR(&varbody) = SysAllocString(wszBody);
1670 hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy);
1671 ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr);
1673 hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
1674 ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
1675 VariantClear(&varbody);
1677 hr = IXMLHttpRequest_get_responseText(pXMLHttpRequest, &bstrResponse);
1678 ok(hr == S_OK, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr);
1679 /* the server currently returns "FAILED" because the Content-Type header is
1680 * not what the server expects */
1681 ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "bstrResponse differs from what was expected\n");
1682 SysFreeString(bstrResponse);
1685 static void test_IXMLDOMDocument2(void)
1690 IXMLDOMDocument *doc;
1691 IXMLDOMDocument2 *doc2;
1695 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1696 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1700 str = SysAllocString( szComplete4 );
1701 r = IXMLDOMDocument_loadXML( doc, str, &b );
1702 ok( r == S_OK, "loadXML failed\n");
1703 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1704 SysFreeString( str );
1706 r = IXMLDOMDocument_QueryInterface( doc, &IID_IXMLDOMDocument2, (void**)&doc2 );
1707 ok( r == S_OK, "ret %08x\n", r );
1708 ok( doc == (IXMLDOMDocument*)doc2, "interfaces differ\n");
1710 /* we will check if the variant got cleared */
1711 ref = IXMLDOMDocument2_AddRef(doc2);
1712 expect_eq(ref, 3, int, "%d"); /* doc, doc2, AddRef*/
1713 V_VT(&var) = VT_UNKNOWN;
1714 V_UNKNOWN(&var) = (IUnknown *)doc2;
1717 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("askldhfaklsdf"), &var), E_FAIL);
1718 expect_eq(V_VT(&var), VT_UNKNOWN, int, "%x");
1719 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), NULL), E_INVALIDARG);
1722 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
1723 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1724 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
1727 /* the variant didn't get cleared*/
1728 expect_eq(IXMLDOMDocument2_Release(doc2), 2, int, "%d");
1730 /* setProperty tests */
1731 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("askldhfaklsdf"), var), E_FAIL);
1732 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), var), E_FAIL);
1733 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL);
1734 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1735 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1736 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1738 /* contrary to what MSDN calims you can switch back from XPath to XSLPattern */
1739 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
1740 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1741 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
1743 IXMLDOMDocument2_Release( doc2 );
1744 IXMLDOMDocument_Release( doc );
1748 static void test_XPath(void)
1753 IXMLDOMDocument2 *doc;
1754 IXMLDOMNode *rootNode;
1755 IXMLDOMNode *elem1Node;
1757 IXMLDOMNodeList *list;
1759 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1760 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
1764 ole_check(IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &b));
1765 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1767 /* switch to XPath */
1768 ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1770 /* some simple queries*/
1771 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root"), &list));
1772 ole_check(IXMLDOMNodeList_get_item(list, 0, &rootNode));
1773 ole_check(IXMLDOMNodeList_reset(list));
1774 expect_list_and_release(list, "E2.D1");
1775 if (rootNode == NULL)
1778 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//c"), &list));
1779 expect_list_and_release(list, "E3.E1.E2.D1 E3.E2.E2.D1");
1781 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//c[@type]"), &list));
1782 expect_list_and_release(list, "E3.E2.E2.D1");
1784 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem"), &list));
1785 /* using get_item for query results advances the position */
1786 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
1787 expect_node(node, "E2.E2.D1");
1788 IXMLDOMNode_Release(node);
1789 ole_check(IXMLDOMNodeList_nextNode(list, &node));
1790 expect_node(node, "E4.E2.D1");
1791 IXMLDOMNode_Release(node);
1792 ole_check(IXMLDOMNodeList_reset(list));
1793 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
1795 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("."), &list));
1796 expect_list_and_release(list, "E2.D1");
1798 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem[3]/preceding-sibling::*"), &list));
1799 ole_check(IXMLDOMNodeList_get_item(list, 0, &elem1Node));
1800 ole_check(IXMLDOMNodeList_reset(list));
1801 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
1803 /* select an attribute */
1804 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//@type"), &list));
1805 expect_list_and_release(list, "A'type'.E3.E2.E2.D1");
1807 /* would evaluate to a number */
1808 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("count(*)"), &list), E_FAIL);
1809 /* would evaluate to a boolean */
1810 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("position()>0"), &list), E_FAIL);
1811 /* would evaluate to a string */
1812 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("name()"), &list), E_FAIL);
1815 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("c"), &list));
1816 expect_list_and_release(list, "");
1817 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("elem//c"), &list));
1818 expect_list_and_release(list, "");
1819 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//elem[4]"), &list));
1820 expect_list_and_release(list, "");
1822 /* foo undeclared in document node */
1823 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1824 /* undeclared in <root> node */
1825 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//foo:c"), &list), E_FAIL);
1826 /* undeclared in <elem> node */
1827 ole_expect(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//foo:c"), &list), E_FAIL);
1828 /* but this trick can be used */
1829 ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//*[name()='foo:c']"), &list));
1830 expect_list_and_release(list, "E3.E4.E2.D1");
1832 /* it has to be declared in SelectionNamespaces */
1833 todo_wine ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1834 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
1836 /* now the namespace can be used */
1837 todo_wine ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//test:c"), &list));
1838 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1839 todo_wine ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//test:c"), &list));
1840 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1841 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//test:c"), &list));
1842 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1843 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_(".//test:x"), &list));
1844 todo_wine expect_list_and_release(list, "E5.E1.E4.E1.E2.D1");
1846 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
1847 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1848 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL);
1850 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1853 todo_wine ole_check(IXMLDOMDocument2_getProperty(doc, _bstr_("SelectionNamespaces"), &var));
1854 todo_wine expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1855 if (V_VT(&var) == VT_BSTR)
1856 expect_bstr_eq_and_free(V_BSTR(&var), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
1858 /* extra attributes - same thing*/
1859 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1860 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL);
1861 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1863 IXMLDOMNode_Release(rootNode);
1864 IXMLDOMNode_Release(elem1Node);
1865 IXMLDOMDocument_Release(doc);
1869 static void test_cloneNode(void )
1871 IXMLDOMDocument *doc = NULL;
1873 IXMLDOMNodeList *pList;
1874 IXMLDOMNamedNodeMap *mapAttr;
1875 long nLength = 0, nLength1 = 0;
1876 long nAttrCnt = 0, nAttrCnt1 = 0;
1878 IXMLDOMNode *node_clone;
1881 static const WCHAR szSearch[] = { 'l', 'c', '/', 'p', 'r', 0 };
1883 r = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
1887 str = SysAllocString( szComplete4 );
1888 ole_check(IXMLDOMDocument_loadXML(doc, str, &b));
1889 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1895 str = SysAllocString( szSearch);
1896 r = IXMLDOMNode_selectSingleNode(doc, str, &node);
1897 ok( r == S_OK, "ret %08x\n", r );
1898 ok( node != NULL, "node %p\n", node );
1903 IXMLDOMDocument_Release(doc);
1907 /* Check invalid parameter */
1908 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, NULL);
1909 ok( r == E_INVALIDARG, "ret %08x\n", r );
1912 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, &node_clone);
1913 ok( r == S_OK, "ret %08x\n", r );
1914 ok( node_clone != NULL, "node %p\n", node );
1918 IXMLDOMDocument_Release(doc);
1919 IXMLDOMNode_Release(node);
1923 r = IXMLDOMNode_get_childNodes(node, &pList);
1924 ok( r == S_OK, "ret %08x\n", r );
1927 IXMLDOMNodeList_get_length(pList, &nLength);
1928 IXMLDOMNodeList_Release(pList);
1931 r = IXMLDOMNode_get_attributes(node, &mapAttr);
1932 ok( r == S_OK, "ret %08x\n", r );
1935 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt);
1936 IXMLDOMNamedNodeMap_Release(mapAttr);
1939 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
1940 ok( r == S_OK, "ret %08x\n", r );
1943 IXMLDOMNodeList_get_length(pList, &nLength1);
1944 IXMLDOMNodeList_Release(pList);
1947 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
1948 ok( r == S_OK, "ret %08x\n", r );
1951 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
1952 IXMLDOMNamedNodeMap_Release(mapAttr);
1955 ok(nLength == nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
1956 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
1957 IXMLDOMNode_Release(node_clone);
1960 r = IXMLDOMNode_cloneNode(node, VARIANT_FALSE, &node_clone);
1961 ok( r == S_OK, "ret %08x\n", r );
1962 ok( node_clone != NULL, "node %p\n", node );
1966 IXMLDOMDocument_Release(doc);
1967 IXMLDOMNode_Release(node);
1971 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
1972 ok( r == S_OK, "ret %08x\n", r );
1975 IXMLDOMNodeList_get_length(pList, &nLength1);
1976 ok( nLength1 == 0, "Length should be 0 (%ld)\n", nLength1);
1977 IXMLDOMNodeList_Release(pList);
1980 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
1981 ok( r == S_OK, "ret %08x\n", r );
1984 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
1985 ok( nAttrCnt1 == 3, "Attribute count should be 3 (%ld)\n", nAttrCnt1);
1986 IXMLDOMNamedNodeMap_Release(mapAttr);
1989 ok(nLength != nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
1990 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
1991 IXMLDOMNode_Release(node_clone);
1994 IXMLDOMNode_Release(node);
1995 IXMLDOMDocument_Release(doc);
1998 static void test_xmlTypes(void)
2000 IXMLDOMDocument *doc = NULL;
2001 IXMLDOMElement *pRoot;
2003 IXMLDOMComment *pComment;
2004 IXMLDOMElement *pElement;
2005 IXMLDOMAttribute *pAttrubute;
2006 IXMLDOMNamedNodeMap *pAttribs;
2007 IXMLDOMCDATASection *pCDataSec;
2008 IXMLDOMImplementation *pIXMLDOMImplementation = NULL;
2009 IXMLDOMDocumentFragment *pDocFrag = NULL;
2010 IXMLDOMEntityReference *pEntityRef = NULL;
2012 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
2016 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2020 hr = IXMLDOMDocument_get_nextSibling(doc, NULL);
2021 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2023 hr = IXMLDOMDocument_get_nextSibling(doc, &pNextChild);
2024 ok(hr == S_FALSE, "ret %08x\n", hr );
2025 ok(pNextChild == NULL, "pDocChild not NULL\n");
2027 /* test previous Sibling */
2028 hr = IXMLDOMDocument_get_previousSibling(doc, NULL);
2029 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2031 pNextChild = (IXMLDOMNode *)0x1;
2032 hr = IXMLDOMDocument_get_previousSibling(doc, &pNextChild);
2033 ok(hr == S_FALSE, "ret %08x\n", hr );
2034 ok(pNextChild == NULL, "pNextChild not NULL\n");
2036 /* test get_attributes */
2037 hr = IXMLDOMDocument_get_attributes( doc, NULL );
2038 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2040 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2041 hr = IXMLDOMDocument_get_attributes( doc, &pAttribs);
2042 ok(hr == S_FALSE, "ret %08x\n", hr );
2043 ok( pAttribs == NULL, "pAttribs not NULL\n");
2045 /* test get_dataType */
2046 hr = IXMLDOMDocument_get_dataType(doc, &v);
2047 ok(hr == S_FALSE, "ret %08x\n", hr );
2048 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2051 /* test nodeTypeString */
2052 hr = IXMLDOMDocument_get_nodeTypeString(doc, &str);
2053 ok(hr == S_OK, "ret %08x\n", hr );
2054 ok( !lstrcmpW( str, _bstr_("document") ), "incorrect nodeTypeString string\n");
2057 /* test implementation */
2058 hr = IXMLDOMDocument_get_implementation(doc, NULL);
2059 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2061 hr = IXMLDOMDocument_get_implementation(doc, &pIXMLDOMImplementation);
2062 ok(hr == S_OK, "ret %08x\n", hr );
2065 VARIANT_BOOL hasFeature = VARIANT_TRUE;
2066 BSTR sEmpty = SysAllocStringLen(NULL, 0);
2068 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, NULL, sEmpty, &hasFeature);
2069 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2071 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, NULL);
2072 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2074 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2075 ok(hr == S_OK, "ret %08x\n", hr );
2076 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2078 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, &hasFeature);
2079 ok(hr == S_OK, "ret %08x\n", hr );
2080 ok(hasFeature == VARIANT_FALSE, "hasFeature returned true\n");
2082 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), NULL, &hasFeature);
2083 ok(hr == S_OK, "ret %08x\n", hr );
2084 ok(hasFeature == VARIANT_TRUE, "hasFeature returned false\n");
2086 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2087 ok(hr == S_OK, "ret %08x\n", hr );
2088 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2090 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), _bstr_("1.0"), &hasFeature);
2091 ok(hr == S_OK, "ret %08x\n", hr );
2092 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2094 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("XML"), _bstr_("1.0"), &hasFeature);
2095 ok(hr == S_OK, "ret %08x\n", hr );
2096 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2098 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature);
2099 ok(hr == S_OK, "ret %08x\n", hr );
2100 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2102 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("SSS"), NULL, &hasFeature);
2103 ok(hr == S_OK, "ret %08x\n", hr );
2104 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2106 SysFreeString(sEmpty);
2107 IXMLDOMImplementation_Release(pIXMLDOMImplementation);
2112 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
2113 ok(hr == S_OK, "ret %08x\n", hr );
2116 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
2117 ok(hr == S_OK, "ret %08x\n", hr );
2121 hr = IXMLDOMDocument_createComment(doc, szComment, &pComment);
2122 ok(hr == S_OK, "ret %08x\n", hr );
2125 /* test get_attributes */
2126 hr = IXMLDOMComment_get_attributes( pComment, NULL );
2127 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2129 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2130 hr = IXMLDOMComment_get_attributes( pComment, &pAttribs);
2131 ok(hr == S_FALSE, "ret %08x\n", hr );
2132 ok( pAttribs == NULL, "pAttribs not NULL\n");
2134 /* test nodeTypeString */
2135 hr = IXMLDOMComment_get_nodeTypeString(pComment, &str);
2136 ok(hr == S_OK, "ret %08x\n", hr );
2137 ok( !lstrcmpW( str, _bstr_("comment") ), "incorrect nodeTypeString string\n");
2140 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pComment, NULL);
2141 ok(hr == S_OK, "ret %08x\n", hr );
2143 hr = IXMLDOMComment_get_nodeName(pComment, &str);
2144 ok(hr == S_OK, "ret %08x\n", hr );
2145 ok( !lstrcmpW( str, szCommentNodeText ), "incorrect comment node Name\n");
2148 hr = IXMLDOMComment_get_xml(pComment, &str);
2149 ok(hr == S_OK, "ret %08x\n", hr );
2150 ok( !lstrcmpW( str, szCommentXML ), "incorrect comment xml\n");
2153 hr = IXMLDOMComment_get_dataType(pComment, &v);
2154 ok(hr == S_FALSE, "ret %08x\n", hr );
2155 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2158 /* put data Tests */
2159 hr = IXMLDOMComment_put_data(pComment, _bstr_("This &is a ; test <>\\"));
2160 ok(hr == S_OK, "ret %08x\n", hr );
2162 /* get data Tests */
2163 hr = IXMLDOMComment_get_data(pComment, &str);
2164 ok(hr == S_OK, "ret %08x\n", hr );
2165 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
2168 /* get data Tests */
2169 hr = IXMLDOMComment_get_nodeValue(pComment, &v);
2170 ok(hr == S_OK, "ret %08x\n", hr );
2171 ok( V_VT(&v) == VT_BSTR, "incorrect dataType type\n");
2172 ok( !lstrcmpW( V_BSTR(&v), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
2175 /* Confirm XML text is good */
2176 hr = IXMLDOMComment_get_xml(pComment, &str);
2177 ok(hr == S_OK, "ret %08x\n", hr );
2178 ok( !lstrcmpW( str, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
2181 /* Confirm we get the put_data Text back */
2182 hr = IXMLDOMComment_get_text(pComment, &str);
2183 ok(hr == S_OK, "ret %08x\n", hr );
2184 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2187 /* test length property */
2188 hr = IXMLDOMComment_get_length(pComment, &len);
2189 ok(hr == S_OK, "ret %08x\n", hr );
2190 ok(len == 21, "expected 21 got %ld\n", len);
2192 /* test substringData */
2193 hr = IXMLDOMComment_substringData(pComment, 0, 4, NULL);
2194 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2196 /* test substringData - Invalid offset */
2197 str = (BSTR)&szElement;
2198 hr = IXMLDOMComment_substringData(pComment, -1, 4, &str);
2199 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2200 ok( str == NULL, "incorrect string\n");
2202 /* test substringData - Invalid offset */
2203 str = (BSTR)&szElement;
2204 hr = IXMLDOMComment_substringData(pComment, 30, 0, &str);
2205 ok(hr == S_FALSE, "ret %08x\n", hr );
2206 ok( str == NULL, "incorrect string\n");
2208 /* test substringData - Invalid size */
2209 str = (BSTR)&szElement;
2210 hr = IXMLDOMComment_substringData(pComment, 0, -1, &str);
2211 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2212 ok( str == NULL, "incorrect string\n");
2214 /* test substringData - Invalid size */
2215 str = (BSTR)&szElement;
2216 hr = IXMLDOMComment_substringData(pComment, 2, 0, &str);
2217 ok(hr == S_FALSE, "ret %08x\n", hr );
2218 ok( str == NULL, "incorrect string\n");
2220 /* test substringData - Start of string */
2221 hr = IXMLDOMComment_substringData(pComment, 0, 4, &str);
2222 ok(hr == S_OK, "ret %08x\n", hr );
2223 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
2226 /* test substringData - Middle of string */
2227 hr = IXMLDOMComment_substringData(pComment, 13, 4, &str);
2228 ok(hr == S_OK, "ret %08x\n", hr );
2229 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
2232 /* test substringData - End of string */
2233 hr = IXMLDOMComment_substringData(pComment, 20, 4, &str);
2234 ok(hr == S_OK, "ret %08x\n", hr );
2235 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
2238 IXMLDOMComment_Release(pComment);
2242 hr = IXMLDOMDocument_createElement(doc, szElement, &pElement);
2243 ok(hr == S_OK, "ret %08x\n", hr );
2246 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2247 ok(hr == S_OK, "ret %08x\n", hr );
2249 /* test nodeTypeString */
2250 hr = IXMLDOMDocument_get_nodeTypeString(pElement, &str);
2251 ok(hr == S_OK, "ret %08x\n", hr );
2252 ok( !lstrcmpW( str, _bstr_("element") ), "incorrect nodeTypeString string\n");
2255 hr = IXMLDOMElement_get_nodeName(pElement, &str);
2256 ok(hr == S_OK, "ret %08x\n", hr );
2257 ok( !lstrcmpW( str, szElement ), "incorrect element node Name\n");
2260 hr = IXMLDOMElement_get_xml(pElement, &str);
2261 ok(hr == S_OK, "ret %08x\n", hr );
2262 ok( !lstrcmpW( str, szElementXML ), "incorrect element xml\n");
2265 hr = IXMLDOMElement_get_dataType(pElement, &v);
2266 ok(hr == S_FALSE, "ret %08x\n", hr );
2267 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2271 hr = IXMLDOMDocument_createAttribute(doc, szAttribute, &pAttrubute);
2272 ok(hr == S_OK, "ret %08x\n", hr );
2275 IXMLDOMNode *pNewChild = (IXMLDOMNode *)0x1;
2277 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, NULL);
2278 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2280 pNextChild = (IXMLDOMNode *)0x1;
2281 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, &pNextChild);
2282 ok(hr == S_FALSE, "ret %08x\n", hr );
2283 ok(pNextChild == NULL, "pNextChild not NULL\n");
2285 /* test Previous Sibling*/
2286 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, NULL);
2287 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2289 pNextChild = (IXMLDOMNode *)0x1;
2290 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, &pNextChild);
2291 ok(hr == S_FALSE, "ret %08x\n", hr );
2292 ok(pNextChild == NULL, "pNextChild not NULL\n");
2294 /* test get_attributes */
2295 hr = IXMLDOMAttribute_get_attributes( pAttrubute, NULL );
2296 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2298 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2299 hr = IXMLDOMAttribute_get_attributes( pAttrubute, &pAttribs);
2300 ok(hr == S_FALSE, "ret %08x\n", hr );
2301 ok( pAttribs == NULL, "pAttribs not NULL\n");
2303 hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttrubute, &pNewChild);
2304 ok(hr == E_FAIL, "ret %08x\n", hr );
2305 ok(pNewChild == NULL, "pNewChild not NULL\n");
2307 hr = IXMLDOMElement_get_attributes(pElement, &pAttribs);
2308 ok(hr == S_OK, "ret %08x\n", hr );
2311 hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttrubute, NULL );
2312 ok(hr == S_OK, "ret %08x\n", hr );
2314 IXMLDOMNamedNodeMap_Release(pAttribs);
2317 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
2318 ok(hr == S_OK, "ret %08x\n", hr );
2319 ok( !lstrcmpW( str, szAttribute ), "incorrect attribute node Name\n");
2322 /* test nodeTypeString */
2323 hr = IXMLDOMAttribute_get_nodeTypeString(pAttrubute, &str);
2324 ok(hr == S_OK, "ret %08x\n", hr );
2325 ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2329 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
2330 ok(hr == S_OK, "ret %08x\n", hr );
2331 ok( !lstrcmpW( str, szAttribute ), "incorrect nodeName string\n");
2334 /* test name property */
2335 hr = IXMLDOMAttribute_get_name(pAttrubute, &str);
2336 ok(hr == S_OK, "ret %08x\n", hr );
2337 ok( !lstrcmpW( str, szAttribute ), "incorrect name string\n");
2340 hr = IXMLDOMAttribute_get_xml(pAttrubute, &str);
2341 ok(hr == S_OK, "ret %08x\n", hr );
2342 ok( !lstrcmpW( str, szAttributeXML ), "incorrect attribute xml\n");
2345 hr = IXMLDOMAttribute_get_dataType(pAttrubute, &v);
2346 ok(hr == S_FALSE, "ret %08x\n", hr );
2347 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2350 IXMLDOMAttribute_Release(pAttrubute);
2352 /* Check Element again with the Add Attribute*/
2353 hr = IXMLDOMElement_get_xml(pElement, &str);
2354 ok(hr == S_OK, "ret %08x\n", hr );
2355 ok( !lstrcmpW( str, szElementXML2 ), "incorrect element xml\n");
2359 hr = IXMLDOMElement_put_text(pElement, _bstr_("TestingNode"));
2360 ok(hr == S_OK, "ret %08x\n", hr );
2362 hr = IXMLDOMElement_get_xml(pElement, &str);
2363 ok(hr == S_OK, "ret %08x\n", hr );
2364 ok( !lstrcmpW( str, szElementXML3 ), "incorrect element xml\n");
2367 IXMLDOMElement_Release(pElement);
2371 hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL);
2372 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2374 hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec);
2375 ok(hr == S_OK, "ret %08x\n", hr );
2378 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
2381 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pCDataSec, NULL);
2382 ok(hr == S_OK, "ret %08x\n", hr );
2384 /* get Attribute Tests */
2385 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, NULL);
2386 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2388 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2389 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, &pAttribs);
2390 ok(hr == S_FALSE, "ret %08x\n", hr );
2391 ok(pAttribs == NULL, "pAttribs != NULL\n");
2393 hr = IXMLDOMCDATASection_get_nodeName(pCDataSec, &str);
2394 ok(hr == S_OK, "ret %08x\n", hr );
2395 ok( !lstrcmpW( str, szCDataNodeText ), "incorrect cdata node Name\n");
2398 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
2399 ok(hr == S_OK, "ret %08x\n", hr );
2400 ok( !lstrcmpW( str, szCDataXML ), "incorrect cdata xml\n");
2403 /* test lastChild */
2404 pNextChild = (IXMLDOMNode*)0x1;
2405 hr = IXMLDOMCDATASection_get_lastChild(pCDataSec, &pNextChild);
2406 ok(hr == S_FALSE, "ret %08x\n", hr );
2407 ok(pNextChild == NULL, "pNextChild not NULL\n");
2409 /* test get_dataType */
2410 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, NULL);
2411 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2413 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, &v);
2414 ok(hr == S_FALSE, "ret %08x\n", hr );
2415 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2418 /* test nodeTypeString */
2419 hr = IXMLDOMCDATASection_get_nodeTypeString(pCDataSec, &str);
2420 ok(hr == S_OK, "ret %08x\n", hr );
2421 ok( !lstrcmpW( str, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
2424 /* put data Tests */
2425 hr = IXMLDOMCDATASection_put_data(pCDataSec, _bstr_("This &is a ; test <>\\"));
2426 ok(hr == S_OK, "ret %08x\n", hr );
2428 /* Confirm XML text is good */
2429 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
2430 ok(hr == S_OK, "ret %08x\n", hr );
2431 ok( !lstrcmpW( str, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
2434 /* Confirm we get the put_data Text back */
2435 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
2436 ok(hr == S_OK, "ret %08x\n", hr );
2437 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2440 /* test length property */
2441 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
2442 ok(hr == S_OK, "ret %08x\n", hr );
2443 ok(len == 21, "expected 21 got %ld\n", len);
2445 /* test get nodeValue */
2446 hr = IXMLDOMCDATASection_get_nodeValue(pCDataSec, &var);
2447 ok(hr == S_OK, "ret %08x\n", hr );
2448 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2452 hr = IXMLDOMCDATASection_get_data(pCDataSec, &str);
2453 ok(hr == S_OK, "ret %08x\n", hr );
2454 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2457 /* test substringData */
2458 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, NULL);
2459 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2461 /* test substringData - Invalid offset */
2462 str = (BSTR)&szElement;
2463 hr = IXMLDOMCDATASection_substringData(pCDataSec, -1, 4, &str);
2464 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2465 ok( str == NULL, "incorrect string\n");
2467 /* test substringData - Invalid offset */
2468 str = (BSTR)&szElement;
2469 hr = IXMLDOMCDATASection_substringData(pCDataSec, 30, 0, &str);
2470 ok(hr == S_FALSE, "ret %08x\n", hr );
2471 ok( str == NULL, "incorrect string\n");
2473 /* test substringData - Invalid size */
2474 str = (BSTR)&szElement;
2475 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, -1, &str);
2476 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2477 ok( str == NULL, "incorrect string\n");
2479 /* test substringData - Invalid size */
2480 str = (BSTR)&szElement;
2481 hr = IXMLDOMCDATASection_substringData(pCDataSec, 2, 0, &str);
2482 ok(hr == S_FALSE, "ret %08x\n", hr );
2483 ok( str == NULL, "incorrect string\n");
2485 /* test substringData - Start of string */
2486 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, &str);
2487 ok(hr == S_OK, "ret %08x\n", hr );
2488 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
2491 /* test substringData - Middle of string */
2492 hr = IXMLDOMCDATASection_substringData(pCDataSec, 13, 4, &str);
2493 ok(hr == S_OK, "ret %08x\n", hr );
2494 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
2497 /* test substringData - End of string */
2498 hr = IXMLDOMCDATASection_substringData(pCDataSec, 20, 4, &str);
2499 ok(hr == S_OK, "ret %08x\n", hr );
2500 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
2503 IXMLDOMCDATASection_Release(pCDataSec);
2506 /* Document Fragments */
2507 hr = IXMLDOMDocument_createDocumentFragment(doc, NULL);
2508 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2510 hr = IXMLDOMDocument_createDocumentFragment(doc, &pDocFrag);
2511 ok(hr == S_OK, "ret %08x\n", hr );
2514 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
2516 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pDocFrag, NULL);
2517 ok(hr == S_OK, "ret %08x\n", hr );
2519 /* get Attribute Tests */
2520 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, NULL);
2521 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2523 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2524 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, &pAttribs);
2525 ok(hr == S_FALSE, "ret %08x\n", hr );
2526 ok(pAttribs == NULL, "pAttribs != NULL\n");
2528 hr = IXMLDOMDocumentFragment_get_nodeName(pDocFrag, &str);
2529 ok(hr == S_OK, "ret %08x\n", hr );
2530 ok( !lstrcmpW( str, szDocFragmentText ), "incorrect docfragment node Name\n");
2533 /* test next Sibling*/
2534 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, NULL);
2535 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2537 pNextChild = (IXMLDOMNode *)0x1;
2538 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &pNextChild);
2539 ok(hr == S_FALSE, "ret %08x\n", hr );
2540 ok(pNextChild == NULL, "pNextChild not NULL\n");
2542 /* test Previous Sibling*/
2543 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, NULL);
2544 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2546 pNextChild = (IXMLDOMNode *)0x1;
2547 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &pNextChild);
2548 ok(hr == S_FALSE, "ret %08x\n", hr );
2549 ok(pNextChild == NULL, "pNextChild not NULL\n");
2551 /* test get_dataType */
2552 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, NULL);
2553 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2555 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, &v);
2556 ok(hr == S_FALSE, "ret %08x\n", hr );
2557 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2560 /* test nodeTypeString */
2561 hr = IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag, &str);
2562 ok(hr == S_OK, "ret %08x\n", hr );
2563 ok( !lstrcmpW( str, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
2566 IXMLDOMDocumentFragment_Release(pDocFrag);
2569 /* Entity References */
2570 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, NULL);
2571 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2573 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, &pEntityRef);
2574 ok(hr == S_OK, "ret %08x\n", hr );
2577 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pEntityRef, NULL);
2578 ok(hr == S_OK, "ret %08x\n", hr );
2580 /* get Attribute Tests */
2581 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, NULL);
2582 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2584 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2585 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, &pAttribs);
2586 ok(hr == S_FALSE, "ret %08x\n", hr );
2587 ok(pAttribs == NULL, "pAttribs != NULL\n");
2590 hr = IXMLDOMEntityReference_get_dataType(pEntityRef, &v);
2591 ok(hr == S_FALSE, "ret %08x\n", hr );
2592 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2595 /* test nodeTypeString */
2596 hr = IXMLDOMEntityReference_get_nodeTypeString(pEntityRef, &str);
2597 ok(hr == S_OK, "ret %08x\n", hr );
2598 ok( !lstrcmpW( str, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
2602 hr = IXMLDOMEntityReference_get_xml(pEntityRef, &str);
2603 ok(hr == S_OK, "ret %08x\n", hr );
2604 ok( !lstrcmpW( str, szEntityRefXML ), "incorrect xml string\n");
2607 IXMLDOMEntityReference_Release(pEntityRef);
2610 IXMLDOMElement_Release( pRoot );
2614 IXMLDOMDocument_Release(doc);
2619 static void test_nodeTypeTests( void )
2621 IXMLDOMDocument *doc = NULL;
2622 IXMLDOMElement *pRoot;
2623 IXMLDOMElement *pElement;
2626 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2630 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
2631 ok(hr == S_OK, "ret %08x\n", hr );
2634 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
2635 ok(hr == S_OK, "ret %08x\n", hr );
2638 hr = IXMLDOMElement_put_dataType(pRoot, NULL);
2639 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2642 hr = IXMLDOMElement_put_dataType(pRoot, _bstr_("abcdefg") );
2643 ok(hr == E_FAIL, "ret %08x\n", hr );
2646 * The name passed into put_dataType is case-insensitive. So many of the names
2647 * have been changed to reflect this.
2650 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Boolean"), &pElement);
2651 ok(hr == S_OK, "ret %08x\n", hr );
2654 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2656 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Boolean") );
2657 ok(hr == S_OK, "ret %08x\n", hr );
2659 IXMLDOMElement_Release(pElement);
2663 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_String"), &pElement);
2664 ok(hr == S_OK, "ret %08x\n", hr );
2667 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2669 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("String") );
2670 ok(hr == S_OK, "ret %08x\n", hr );
2672 IXMLDOMElement_Release(pElement);
2676 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Number"), &pElement);
2677 ok(hr == S_OK, "ret %08x\n", hr );
2680 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2682 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("number") );
2683 ok(hr == S_OK, "ret %08x\n", hr );
2685 IXMLDOMElement_Release(pElement);
2689 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Int"), &pElement);
2690 ok(hr == S_OK, "ret %08x\n", hr );
2693 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2695 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("InT") );
2696 ok(hr == S_OK, "ret %08x\n", hr );
2698 IXMLDOMElement_Release(pElement);
2702 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Fixed"), &pElement);
2703 ok(hr == S_OK, "ret %08x\n", hr );
2706 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2708 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("fixed.14.4") );
2709 ok(hr == S_OK, "ret %08x\n", hr );
2711 IXMLDOMElement_Release(pElement);
2715 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime"), &pElement);
2716 ok(hr == S_OK, "ret %08x\n", hr );
2719 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2721 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime") );
2722 ok(hr == S_OK, "ret %08x\n", hr );
2724 IXMLDOMElement_Release(pElement);
2728 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime_tz"), &pElement);
2729 ok(hr == S_OK, "ret %08x\n", hr );
2732 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2734 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
2735 ok(hr == S_OK, "ret %08x\n", hr );
2737 IXMLDOMElement_Release(pElement);
2741 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Date"), &pElement);
2742 ok(hr == S_OK, "ret %08x\n", hr );
2745 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2747 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Date") );
2748 ok(hr == S_OK, "ret %08x\n", hr );
2750 IXMLDOMElement_Release(pElement);
2754 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time"), &pElement);
2755 ok(hr == S_OK, "ret %08x\n", hr );
2758 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2760 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time") );
2761 ok(hr == S_OK, "ret %08x\n", hr );
2763 IXMLDOMElement_Release(pElement);
2767 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time_TZ"), &pElement);
2768 ok(hr == S_OK, "ret %08x\n", hr );
2771 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2773 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time.tz") );
2774 ok(hr == S_OK, "ret %08x\n", hr );
2776 IXMLDOMElement_Release(pElement);
2780 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I1"), &pElement);
2781 ok(hr == S_OK, "ret %08x\n", hr );
2784 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2786 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I1") );
2787 ok(hr == S_OK, "ret %08x\n", hr );
2789 IXMLDOMElement_Release(pElement);
2793 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I2"), &pElement);
2794 ok(hr == S_OK, "ret %08x\n", hr );
2797 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2799 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I2") );
2800 ok(hr == S_OK, "ret %08x\n", hr );
2802 IXMLDOMElement_Release(pElement);
2806 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I4"), &pElement);
2807 ok(hr == S_OK, "ret %08x\n", hr );
2810 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2812 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I4") );
2813 ok(hr == S_OK, "ret %08x\n", hr );
2815 IXMLDOMElement_Release(pElement);
2819 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI1"), &pElement);
2820 ok(hr == S_OK, "ret %08x\n", hr );
2823 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2825 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI1") );
2826 ok(hr == S_OK, "ret %08x\n", hr );
2828 IXMLDOMElement_Release(pElement);
2832 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI2"), &pElement);
2833 ok(hr == S_OK, "ret %08x\n", hr );
2836 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2838 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI2") );
2839 ok(hr == S_OK, "ret %08x\n", hr );
2841 IXMLDOMElement_Release(pElement);
2845 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI4"), &pElement);
2846 ok(hr == S_OK, "ret %08x\n", hr );
2849 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2851 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI4") );
2852 ok(hr == S_OK, "ret %08x\n", hr );
2854 IXMLDOMElement_Release(pElement);
2858 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r4"), &pElement);
2859 ok(hr == S_OK, "ret %08x\n", hr );
2862 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2864 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r4") );
2865 ok(hr == S_OK, "ret %08x\n", hr );
2867 IXMLDOMElement_Release(pElement);
2871 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r8"), &pElement);
2872 ok(hr == S_OK, "ret %08x\n", hr );
2875 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2877 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r8") );
2878 ok(hr == S_OK, "ret %08x\n", hr );
2880 IXMLDOMElement_Release(pElement);
2884 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_float"), &pElement);
2885 ok(hr == S_OK, "ret %08x\n", hr );
2888 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2890 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("float") );
2891 ok(hr == S_OK, "ret %08x\n", hr );
2893 IXMLDOMElement_Release(pElement);
2897 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_uuid"), &pElement);
2898 ok(hr == S_OK, "ret %08x\n", hr );
2901 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2903 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UuId") );
2904 ok(hr == S_OK, "ret %08x\n", hr );
2906 IXMLDOMElement_Release(pElement);
2910 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_hex"), &pElement);
2911 ok(hr == S_OK, "ret %08x\n", hr );
2914 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2916 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.hex") );
2917 ok(hr == S_OK, "ret %08x\n", hr );
2919 IXMLDOMElement_Release(pElement);
2923 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_base64"), &pElement);
2924 ok(hr == S_OK, "ret %08x\n", hr );
2927 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2929 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.base64") );
2930 ok(hr == S_OK, "ret %08x\n", hr );
2932 IXMLDOMElement_Release(pElement);
2935 /* Check changing types */
2936 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Change"), &pElement);
2937 ok(hr == S_OK, "ret %08x\n", hr );
2940 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2942 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
2943 ok(hr == S_OK, "ret %08x\n", hr );
2945 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("string") );
2946 ok(hr == S_OK, "ret %08x\n", hr );
2948 IXMLDOMElement_Release(pElement);
2951 IXMLDOMElement_Release(pRoot);
2955 IXMLDOMDocument_Release(doc);
2964 r = CoInitialize( NULL );
2965 ok( r == S_OK, "failed to init com\n");
2971 test_getElementsByTagName();
2973 test_get_childNodes();
2976 test_IXMLDOMDocument2();
2980 test_nodeTypeTests();