Commit 549befe7 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msxml3: Use xmlNodeGetContent to get text data.

parent c6458f0f
......@@ -864,32 +864,18 @@ static HRESULT WINAPI xmlnode_get_text(
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
BSTR str = NULL;
xmlChar *pContent;
TRACE("%p\n", This);
TRACE("%p type %d\n", This, This->node->type);
if ( !text )
return E_INVALIDARG;
switch(This->node->type)
{
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
pContent = xmlNodeGetContent((xmlNodePtr)This->node);
if(pContent)
{
xmlNodePtr child = This->node->children;
if ( child && child->type == XML_TEXT_NODE )
str = bstr_from_xmlChar( child->content );
break;
}
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
str = bstr_from_xmlChar( This->node->content );
break;
default:
FIXME("Unhandled node type %d\n", This->node->type);
str = bstr_from_xmlChar(pContent);
xmlFree(pContent);
}
/* Always return a string. */
......
......@@ -260,6 +260,20 @@ static BOOL compareIgnoreReturns(BSTR sLeft, BSTR sRight)
}
}
static BOOL compareIgnoreReturnsWhitespace(BSTR sLeft, BSTR sRight)
{
/* MSXML3 inserts whitespace where as libxml doesn't. */
for (;;)
{
while (*sLeft == '\r' || *sLeft == '\n' || *sLeft == ' ') sLeft++;
while (*sRight == '\r' || *sRight == '\n' || *sRight == ' ') sRight++;
if (*sLeft != *sRight) return FALSE;
if (!*sLeft) return TRUE;
sLeft++;
sRight++;
}
}
static void get_str_for_type(DOMNodeType type, char *buf)
{
switch (type)
......@@ -1706,6 +1720,7 @@ static void test_get_text(void)
VARIANT_BOOL b;
IXMLDOMDocument *doc;
IXMLDOMNode *node, *node2, *node3;
IXMLDOMNode *nodeRoot;
IXMLDOMNodeList *node_list;
IXMLDOMNamedNodeMap *node_map;
long len;
......@@ -1726,6 +1741,19 @@ static void test_get_text(void)
ok( r == S_OK, "ret %08x\n", r );
SysFreeString(str);
/* Test to get all child node text. */
r = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMNode, (LPVOID*)&nodeRoot);
ok( r == S_OK, "ret %08x\n", r );
if(r == S_OK)
{
r = IXMLDOMNode_get_text( nodeRoot, &str );
ok( r == S_OK, "ret %08x\n", r );
ok( compareIgnoreReturnsWhitespace(str, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text\n");
SysFreeString(str);
IXMLDOMNode_Release(nodeRoot);
}
if (0) {
/* this test crashes on win9x */
r = IXMLDOMNodeList_QueryInterface(node_list, &IID_IDispatch, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment