{
    "mode": "perldoc",
    "parameter": "XML::LibXML::Devel",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ALibXML%3A%3ADevel/json",
    "generated": "2026-06-10T16:29:12Z",
    "synopsis": "/\n* C functions you want to access\n*/\nxmlNode *returnnode();\nvoid receivenode(xmlNode *);\n###############################################\n# XS Code\nvoid *\nxsreturnnode\nCODE:\nRETVAL = returnnode();\nOUTPUT:\nRETVAL\nvoid\nxsreceivenode\nvoid *n\nCODE:\nreceivenode(n);\n###############################################\n# Perl code\nuse XML::LibXML::Devel;\nsub returnnode\n{\nmy $rawnode = xsreturnnode();\nmy $node = XML::LibXML::Devel::nodetoperl($rawnode);\nXML::LibXML::Devel::refcntinc($rawnode);\nreturn $node;\n}\nsub receivenode\n{\nmy ($node) = @;\nmy $rawnode = XML::LibXML::Devel::nodefromperl($node);\nxsreceivenode($rawnode);\nXML::LibXML::Devel::refcntinc($rawnode);\n}",
    "sections": {
        "NAME": {
            "content": "XML::LibXML::Devel - makes functions from LibXML.xs available\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "/\n* C functions you want to access\n*/\nxmlNode *returnnode();\nvoid receivenode(xmlNode *);\n\n###############################################\n# XS Code\nvoid *\nxsreturnnode\nCODE:\nRETVAL = returnnode();\nOUTPUT:\nRETVAL\n\nvoid\nxsreceivenode\nvoid *n\nCODE:\nreceivenode(n);\n\n###############################################\n# Perl code\nuse XML::LibXML::Devel;\n\nsub returnnode\n{\nmy $rawnode = xsreturnnode();\nmy $node = XML::LibXML::Devel::nodetoperl($rawnode);\nXML::LibXML::Devel::refcntinc($rawnode);\nreturn $node;\n}\n\nsub receivenode\n{\nmy ($node) = @;\nmy $rawnode = XML::LibXML::Devel::nodefromperl($node);\nxsreceivenode($rawnode);\nXML::LibXML::Devel::refcntinc($rawnode);\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"XML::LibXML::Devel\" makes functions from LibXML.xs available that are needed to wrap libxml2\nnodes in and out of XML::LibXML::Nodes. This gives cleaner dependencies than using LibXML.so\ndirectly.\n\nTo XS a library that uses libxml2 nodes the first step is to do this so that xmlNodePtr is\npassed as void *. These raw nodes are then turned into libxml nodes by using this \"Devel\"\nfunctions.\n\nBe aware that this module is currently rather experimental. The function names may change if I\nXS more functions and introduce a reasonable naming convention.\n\nBe also aware that this module is a great tool to cause segfaults and introduce memory leaks. It\ndoes however provide a partial cure by making \"xmlMemUsed\" available as \"memused\".\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "NODE MANAGEMENT\nnodetoperl\nnodetoperl($rawnode);\n\nReturns a LibXML::Node object. This has a proxy node with a reference counter and an owner\nattached. The raw node will be deleted as soon as the reference counter reaches zero. If the C\nlibrary is keeping a pointer to the raw node, you need to call refcntinc immediately. You also\nneed to replace xmlFreeNode by a call to refcntdec.\n\nnodetoperl\nnodefromperl($node);\n\nReturns a raw node. This is a void * pointer and you can do nothing but passing it to functions\nthat treat it as an xmlNodePtr. The raw node will be freed as soon as its reference counter\nreaches zero. If the C library is keeping a pointer to the raw node, you need to call\nrefcntinc immediately. You also need to replace xmlFreeNode by a call to refcntdec.\n\nrefcntinc\nrefcntinc($rawnode);\n\nIncrements the raw nodes reference counter. The raw node must already be known to perl to have\na reference counter.\n\nrefcntdec\nrefcntdec($rawnode);\n\nDecrements the raw nodes reference counter and returns the value it had before. if the counter\nbecomes zero or less, this method will free the proxy node holding the reference counter. If\nthe node is part of a subtree, refcntdec will fix the reference counts and delete the subtree\nif it is not required any more.\n\nrefcnt\nrefcnt($rawnode);\n\nReturns the value of the reference counter.\n\nfixowner\nfixowner($rawnode, $rawparent);\n\nThis functions fixes the reference counts for an entire subtree. it is very important to fix an\nentire subtree after node operations where the documents or the owner node may get changed.\nthis method is aware about nodes that already belong to a certain owner node.\n\nMEMORY DEBUGGING\n$ENV{DEBUGMEMORY}\nBEGIN {$ENV{DEBUGMEMORY} = 1;};\nuse XML::LibXML;\n\nThis turns on libxml2 memory debugging. It must be set before XML::LibXML is loaded.\n\nmemused\nmemused();\n\nReturns the number of bytes currently allocated.\n\nEXPORT\nNone by default.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "This was created to support the needs of Apache2::ModXml2. So this can serve as an example.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Joachim Zobel <jz-2011@heute-morgen.de>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (C) 2011 by Joachim Zobel\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may\nhave available.\n",
            "subsections": []
        }
    },
    "summary": "XML::LibXML::Devel - makes functions from LibXML.xs available",
    "flags": [],
    "examples": [],
    "see_also": []
}