Made the result of first XPath evaluation the same as those of the others Fixed a potential memory leak
This commit is contained in:
parent
cb82a3c856
commit
9a9cf0e724
|
@ -214,8 +214,7 @@ bool WrapLibxml::parse (
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( indent )
|
||||
xmlKeepBlanksDefault ( 0 );
|
||||
xmlKeepBlanksDefault ( indent ? 0 : 1 );
|
||||
|
||||
xmlChar *buf = NULL;
|
||||
int size;
|
||||
|
@ -251,6 +250,8 @@ bool WrapLibxml::xpath ( const std::string& path, const std::string& fileName )
|
|||
xmlParserCtxtPtr ctxt;
|
||||
xmlDocPtr docPtr;
|
||||
|
||||
xmlKeepBlanksDefault ( 0 );
|
||||
|
||||
ctxt = xmlNewParserCtxt();
|
||||
if ( ctxt == NULL )
|
||||
{
|
||||
|
@ -290,27 +291,27 @@ bool WrapLibxml::xpath ( const std::string& path, const std::string& fileName )
|
|||
|
||||
result = xmlXPathEvalExpression ( ( const xmlChar * ) path.c_str(), context );
|
||||
|
||||
xmlKeepBlanksDefault ( 0 );
|
||||
|
||||
bool xpathIsValid = ( result ) ? true : false;
|
||||
|
||||
while ( result != NULL )
|
||||
{
|
||||
if ( xmlXPathNodeSetIsEmpty ( result->nodesetval ) )
|
||||
break;
|
||||
xmlBufferPtr bufferPtr = xmlBufferCreate();
|
||||
if ( bufferPtr == NULL )
|
||||
break;
|
||||
nodeset = result->nodesetval;
|
||||
for ( int i = 0; i < nodeset->nodeNr; i++ )
|
||||
{
|
||||
xmlNodePtr node = nodeset->nodeTab[i];
|
||||
xmlBufferPtr bufferPtr = xmlBufferCreate();
|
||||
if ( !node || !bufferPtr )
|
||||
if ( !node )
|
||||
break;
|
||||
xmlNodeDump ( bufferPtr, NULL, node, 0, 1 );
|
||||
std::string nodeBuffer = ( const char * ) xmlBufferContent ( bufferPtr );
|
||||
|
||||
output += nodeBuffer;
|
||||
output += ( const char * ) xmlBufferContent ( bufferPtr );
|
||||
output += '\n';
|
||||
}
|
||||
xmlBufferFree ( bufferPtr );
|
||||
break;
|
||||
}
|
||||
if ( result )
|
||||
|
|
|
@ -5840,7 +5840,7 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
|
|||
std::string origEncoding = XmlEncodingHandler::get ( utf8Buffer );
|
||||
XmlEncodingHandler::setUtf8 ( utf8Buffer, true );
|
||||
std::auto_ptr<WrapExpat> wellformedparser ( new WrapExpat() );
|
||||
if ( !wellformedparser->parse ( utf8Buffer ) ) // FIXME: Set encoding to UTF-8 before parsing.
|
||||
if ( !wellformedparser->parse ( utf8Buffer ) )
|
||||
{
|
||||
std::string error = wellformedparser->getLastError();
|
||||
wxString wideError = wxString ( error.c_str(), wxConvUTF8, error.size() );
|
||||
|
|
Loading…
Reference in New Issue