msxml3: Use xmlNodeGetContent to get text data.
This commit is contained in:
parent
c6458f0fa6
commit
549befe706
|
@ -864,32 +864,18 @@ static HRESULT WINAPI xmlnode_get_text(
|
||||||
{
|
{
|
||||||
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
||||||
BSTR str = NULL;
|
BSTR str = NULL;
|
||||||
|
xmlChar *pContent;
|
||||||
|
|
||||||
TRACE("%p\n", This);
|
TRACE("%p type %d\n", This, This->node->type);
|
||||||
|
|
||||||
if ( !text )
|
if ( !text )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
switch(This->node->type)
|
pContent = xmlNodeGetContent((xmlNodePtr)This->node);
|
||||||
|
if(pContent)
|
||||||
{
|
{
|
||||||
case XML_ELEMENT_NODE:
|
str = bstr_from_xmlChar(pContent);
|
||||||
case XML_ATTRIBUTE_NODE:
|
xmlFree(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always return a string. */
|
/* 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)
|
static void get_str_for_type(DOMNodeType type, char *buf)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -1706,6 +1720,7 @@ static void test_get_text(void)
|
||||||
VARIANT_BOOL b;
|
VARIANT_BOOL b;
|
||||||
IXMLDOMDocument *doc;
|
IXMLDOMDocument *doc;
|
||||||
IXMLDOMNode *node, *node2, *node3;
|
IXMLDOMNode *node, *node2, *node3;
|
||||||
|
IXMLDOMNode *nodeRoot;
|
||||||
IXMLDOMNodeList *node_list;
|
IXMLDOMNodeList *node_list;
|
||||||
IXMLDOMNamedNodeMap *node_map;
|
IXMLDOMNamedNodeMap *node_map;
|
||||||
long len;
|
long len;
|
||||||
|
@ -1726,6 +1741,19 @@ static void test_get_text(void)
|
||||||
ok( r == S_OK, "ret %08x\n", r );
|
ok( r == S_OK, "ret %08x\n", r );
|
||||||
SysFreeString(str);
|
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) {
|
if (0) {
|
||||||
/* this test crashes on win9x */
|
/* this test crashes on win9x */
|
||||||
r = IXMLDOMNodeList_QueryInterface(node_list, &IID_IDispatch, NULL);
|
r = IXMLDOMNodeList_QueryInterface(node_list, &IID_IDispatch, NULL);
|
||||||
|
|
Loading…
Reference in New Issue