⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ixml.c

📁 基于LINUX/UNIX的UPN库,是智能家具的用的底层库.
💻 C
📖 第 1 页 / 共 2 页
字号:
        return;    }    nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );    nodeValue = ixmlNode_getNodeValue( nodeptr );    switch ( ixmlNode_getNodeType( nodeptr ) ) {        case eTEXT_NODE:        case eCDATA_SECTION_NODE:        case ePROCESSING_INSTRUCTION_NODE:        case eDOCUMENT_NODE:            ixmlPrintDomTreeRecursive( nodeptr, buf );            break;        case eATTRIBUTE_NODE:            ixml_membuf_append_str( buf, nodeName );            ixml_membuf_append_str( buf, "=\"" );            copy_with_escape( buf, nodeValue );            ixml_membuf_append_str( buf, "\"" );            break;        case eELEMENT_NODE:            ixml_membuf_append_str( buf, "<" );            ixml_membuf_append_str( buf, nodeName );            if( nodeptr->firstAttr != NULL ) {                ixml_membuf_append_str( buf, " " );                ixmlPrintDomTreeRecursive( nodeptr->firstAttr, buf );            }            child = ixmlNode_getFirstChild( nodeptr );            if( ( child != NULL )                && ( ixmlNode_getNodeType( child ) == eELEMENT_NODE ) ) {                ixml_membuf_append_str( buf, ">" );            } else {                ixml_membuf_append_str( buf, ">" );            }            //  output the children            ixmlPrintDomTreeRecursive( ixmlNode_getFirstChild( nodeptr ),                                       buf );            // Done with children.  Output the end tag.            ixml_membuf_append_str( buf, "</" );            ixml_membuf_append_str( buf, nodeName );            ixml_membuf_append_str( buf, ">" );            break;        default:            break;    }}/*================================================================*   ixmlLoadDocumentEx*       Parses the given file, and returns the DOM tree from it.*       External function.**=================================================================*/intixmlLoadDocumentEx( IN const char *xmlFile,                    IXML_Document ** doc ){    if( ( xmlFile == NULL ) || ( doc == NULL ) ) {        return IXML_INVALID_PARAMETER;    }    return Parser_LoadDocument( doc, xmlFile, TRUE );}/*================================================================*   ixmlLoadDocument*       Parses the given file, and returns the DOM tree from it.*       External function.**=================================================================*/IXML_Document *ixmlLoadDocument( IN const char *xmlFile ){    IXML_Document *doc = NULL;    ixmlLoadDocumentEx( xmlFile, &doc );    return doc;}/*================================================================*   ixmlPrintDocument*       Prints entire document, prepending XML prolog first.*       Puts lots of white spaces.*       External function.**=================================================================*/DOMStringixmlPrintDocument(IXML_Document *doc){    IXML_Node* rootNode = ( IXML_Node * )doc;    ixml_membuf memBuf;    ixml_membuf *buf = &memBuf;    if( rootNode == NULL ) {        return NULL;    }    ixml_membuf_init( buf );    ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );    ixmlPrintDomTree( rootNode, buf );    return buf->buf;}/*================================================================*   ixmlPrintNode*       Print DOM tree under node. Puts lots of white spaces*       External function.**=================================================================*/DOMStringixmlPrintNode( IN IXML_Node * node ){    ixml_membuf memBuf;    ixml_membuf *buf = &memBuf;    if( node == NULL ) {        return NULL;    }    ixml_membuf_init( buf );    ixmlPrintDomTree( node, buf );    return buf->buf;}/*================================================================*   ixmlDocumenttoString*       converts DOM tree under node to text string,*       prepending XML prolog first.*       External function.**=================================================================*/DOMStringixmlDocumenttoString(IXML_Document *doc){    IXML_Node* rootNode = ( IXML_Node * )doc;    ixml_membuf memBuf;    ixml_membuf *buf = &memBuf;    if( rootNode == NULL ) {        return NULL;    }    ixml_membuf_init( buf );    ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );    ixmlDomTreetoString( rootNode, buf );    return buf->buf;}/*================================================================*   ixmlNodetoString*       converts DOM tree under node to text string*       External function.**=================================================================*/DOMStringixmlNodetoString( IN IXML_Node * node ){    ixml_membuf memBuf;    ixml_membuf *buf = &memBuf;    if( node == NULL ) {        return NULL;    }    ixml_membuf_init( buf );    ixmlDomTreetoString( node, buf );    return buf->buf;}/*================================================================*   ixmlRelaxParser*       Makes the XML parser more tolerant to malformed text.*       External function.**=================================================================*/voidixmlRelaxParser(char errorChar){    Parser_setErrorChar( errorChar );}/*================================================================*   ixmlParseBufferEx*       Parse xml file stored in buffer.*       External function.**=================================================================*/intixmlParseBufferEx( IN const char *buffer,                   IXML_Document ** retDoc ){    if( ( buffer == NULL ) || ( retDoc == NULL ) ) {        return IXML_INVALID_PARAMETER;    }    if( buffer[0] == '\0' ) {        return IXML_INVALID_PARAMETER;    }    return Parser_LoadDocument( retDoc, buffer, FALSE );}/*================================================================*   ixmlParseBuffer*       Parse xml file stored in buffer.*       External function.**=================================================================*/IXML_Document *ixmlParseBuffer( IN const char *buffer ){    IXML_Document *doc = NULL;    ixmlParseBufferEx( buffer, &doc );    return doc;}/*================================================================*   ixmlCloneDOMString*       Clones a DOM String.*       External function.**=================================================================*/DOMStringixmlCloneDOMString( IN const DOMString src ){    if( src == NULL ) {        return NULL;    }    return ( strdup( src ) );}/*================================================================*   ixmlFreeDOMString*       Frees a DOM String.*       External function.**=================================================================*/voidixmlFreeDOMString( IN DOMString buf ){    if( buf != NULL ) {        free( buf );    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -