Implement description for GSXMLNode

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-06-18 10:08:02 +00:00
parent afbfbea856
commit ca3b6b592f
3 changed files with 31 additions and 1 deletions

View file

@ -340,7 +340,7 @@ static NSMapTable *attrNames = 0;
xmlChar *buf = NULL;
int length;
xmlDocDumpMemory(lib, &buf, &length);
xmlDocDumpFormatMemoryEnc(lib, &buf, &length, "utf-8", 1);
if (buf != 0 && length > 0)
{
@ -885,6 +885,31 @@ static NSMapTable *nodeNames = 0;
[super dealloc];
}
/**
* Returns a string representation of the node and all its children
* (ie the XML text) or nil if the node does not have reasonable contents.
*/
- (NSString*) description
{
NSString *string = nil;
xmlOutputBufferPtr buf;
buf = xmlAllocOutputBuffer(0);
if (buf != 0)
{
xmlNodeDumpOutput(buf,
((xmlNodePtr)(lib))->doc,
(xmlNodePtr)(lib),
1,
1,
"utf-8");
xmlOutputBufferFlush(buf);
string = UTF8StrLen(buf->buffer->content, buf->buffer->use);
xmlOutputBufferClose(buf);
}
return string;
}
/**
* Return the document in which this node exists.
*/