Fork me on GitHub

libxml2 解析笔记(原)

  工程TARGET~ BuildPhrase~ LinkBinaryWithLibraries 

   加入         :   libxml2.2.dylib

工程TARGET ~BuildSetting~搜索框中输入:  Header Search Path   

     输入路径 : ${SDKROOT}/usr/include/libxml2.h  

头文件:

         加入   :    import<libxml/tree.h>

点开头文件,查看内容:

                   typedef struct _xmlSAXHandler xmlSAXHandler;

点开    _xmlSAXHandler  ,查看内容

      

struct _xmlSAXHandler {

    internalSubsetSAXFunc internalSubset;

    isStandaloneSAXFunc isStandalone;

    hasInternalSubsetSAXFunc hasInternalSubset;

    hasExternalSubsetSAXFunc hasExternalSubset;

    resolveEntitySAXFunc resolveEntity;

    getEntitySAXFunc getEntity;

    entityDeclSAXFunc entityDecl;

    notationDeclSAXFunc notationDecl;

    attributeDeclSAXFunc attributeDecl;

    elementDeclSAXFunc elementDecl;

    unparsedEntityDeclSAXFunc unparsedEntityDecl;

    setDocumentLocatorSAXFunc setDocumentLocator;

    startDocumentSAXFunc startDocument;

    endDocumentSAXFunc endDocument;

    startElementSAXFunc startElement;

    endElementSAXFunc endElement;

    referenceSAXFunc reference;

    charactersSAXFunc characters;

    ignorableWhitespaceSAXFunc ignorableWhitespace;

    processingInstructionSAXFunc processingInstruction;

    commentSAXFunc comment;

    warningSAXFunc warning;

    errorSAXFunc error;

    fatalErrorSAXFunc fatalError; 

    getParameterEntitySAXFunc getParameterEntity;

    cdataBlockSAXFunc cdataBlock;

    externalSubsetSAXFunc externalSubset;

    unsigned int initialized;

    void *_private;

    startElementNsSAX2Func   startElementNs;

    endElementNsSAX2Func   endElementNs;

    xmlStructuredErrorFunc serror;

};

复制结构体,并改为  :

     static   xmlSAXHandler  simpleSAXHandlerStruct=

      {

        ...NULL,   13

        endDocumentSAX,

        ...NULL,   3

         charactersFoundSAX,

        ...NULL,  4

        errorSAX,

         NULL,     4

        unsigned int initialized;

        NULL,

           startElementSAX,

           endElementSAX,

           NULL,

      };

查看头文件,xmlSAXHandle结构体,上翻,找到

      #define XML_SAX2_MAGIC 0xDEEDBEAF

复制:   XML_SAX2_MAGIC    到  unsigned int initialized;

 

posted on 2012-02-24 21:36  pengyingh  阅读(581)  评论(0)    收藏  举报

导航