{
    "content": [
        {
            "type": "text",
            "text": "# CGI::XMLForm (perldoc)\n\n## NAME\n\nCGI::XMLForm - Extension of CGI.pm which reads/generates formated XML.  NB: This is a subclass of CGI.pm, so can be used in it's place.\n\n## SYNOPSIS\n\nuse CGI::XMLForm;\nmy $cgi = new CGI::XMLForm;\nif ($cgi->param) {\nprint $cgi->header, $cgi->pre($cgi->escapeHTML($cgi->toXML));\n}\nelse {\nopen(FILE, \"test.xml\") or die \"Can't open: $!\";\nmy @queries = ('/a', '/a/b*', '/a/b/c*', /a/d');\nprint $cgi->header,\n$cgi->pre($cgi->escapeHTML(\njoin \"\\n\", $cgi->readXML(*FILE, @queries)));\n}\n\n## DESCRIPTION\n\nThis module can either create form field values from XML based on XQL/XSL style queries (full\nXQL is not supported - this module is designed for speed), or it can create XML from form\nvalues. There are 2 key functions: toXML and readXML.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SYNTAX** (1 subsections)\n- **AUTHOR**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "CGI::XMLForm",
        "section": "",
        "mode": "perldoc",
        "summary": "CGI::XMLForm - Extension of CGI.pm which reads/generates formated XML.  NB: This is a subclass of CGI.pm, so can be used in it's place.",
        "synopsis": "use CGI::XMLForm;\nmy $cgi = new CGI::XMLForm;\nif ($cgi->param) {\nprint $cgi->header, $cgi->pre($cgi->escapeHTML($cgi->toXML));\n}\nelse {\nopen(FILE, \"test.xml\") or die \"Can't open: $!\";\nmy @queries = ('/a', '/a/b*', '/a/b/c*', /a/d');\nprint $cgi->header,\n$cgi->pre($cgi->escapeHTML(\njoin \"\\n\", $cgi->readXML(*FILE, @queries)));\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "CGI",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/CGI/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 56,
                "subsections": []
            },
            {
                "name": "SYNTAX",
                "lines": 129,
                "subsections": [
                    {
                        "name": "Caveats",
                        "lines": 14
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "CGI::XMLForm - Extension of CGI.pm which reads/generates formated XML.\n\nNB: This is a subclass of CGI.pm, so can be used in it's place.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use CGI::XMLForm;\n\nmy $cgi = new CGI::XMLForm;\n\nif ($cgi->param) {\nprint $cgi->header, $cgi->pre($cgi->escapeHTML($cgi->toXML));\n}\nelse {\nopen(FILE, \"test.xml\") or die \"Can't open: $!\";\nmy @queries = ('/a', '/a/b*', '/a/b/c*', /a/d');\nprint $cgi->header,\n$cgi->pre($cgi->escapeHTML(\njoin \"\\n\", $cgi->readXML(*FILE, @queries)));\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module can either create form field values from XML based on XQL/XSL style queries (full\nXQL is not supported - this module is designed for speed), or it can create XML from form\nvalues. There are 2 key functions: toXML and readXML.\n\ntoXML\nThe module takes form fields given in a specialised format, and outputs them to XML based on\nthat format. The idea is that you can create forms that define the resulting XML at the back\nend.\n\nThe format for the form elements is:\n\n<input name=\"/body/p/ul/li\">\n\nwhich creates the following XML:\n\n<body>\n<p>\n<ul>\n<li>Entered Value</li>\n</ul>\n</p>\n</body>\n\nIt's the user's responsibility to design appropriate forms to make use of this module. Details\nof how come below...\n\nAlso supported are attribute form items, that allow creation of element attributes. The syntax\nfor this is:\n\n<input name=\"/body/p[@id='mypara' and @onClick='someFunc()']/@class\">\n\nWhich creates the following XML:\n\n<body>\n<p id=\"mypara\" onClick=\"someFunc()\" class=\"Entered Value\"></p>\n</body>\n\nAlso possible are relative paths. So the following form elements:\n\n<input type=\"hidden\" name=\"/table/tr\">\n<input type=\"text\" name=\"td\">\n<input type=\"text\" name=\"td\">\n<input type=\"text\" name=\"../tr/td\">\n\nWill create the following XML:\n\n<table>\n<tr>\n<td>value1</td>\n<td>value2</td>\n</tr>\n<tr>\n<td>value3</td>\n</tr>\n</table>\n",
                "subsections": []
            },
            "SYNTAX": {
                "content": "The following is a brief syntax guideline\n\nFull paths start with a \"/\" :\n\n\"/table/tr/td\"\n\nRelative paths start with either \"..\" or just a tag name.\n\n\"../tr/td\"\n\"td\"\n\nRelative paths go at the level above the previous path, unless the previous path was also a\nrelative path, in which case it goes at the same level. This seems confusing at first (you might\nexpect it to always go at the level above the previous element), but it makes your form easier\nto design. Take the following example: You have a timesheet (see the example supplied in the\narchive) that has monday,tuesday,etc. Our form can look like this:\n\n<input type=\"text\" name=\"/timesheet/projects/project/@Name\">\n<input type=\"text\" name=\"monday\">\n<input type=\"text\" name=\"tuesday\">\n...\n\nRather than:\n\n<input type=\"text\" name=\"/timesheet/projects/project/@Name\">\n<input type=\"text\" name=\"monday\">\n<input type=\"text\" name=\"../tuesday\">\n<input type=\"text\" name=\"../wednesday\">\n...\n\nIf unsure I recommend using full paths, relative paths are great for repeating groups of data,\nbut weak for heavily structured data. Picture the following paths:\n\n/timesheet/employee/name/forename\n../surname\ntitle\n../department\n\nThis actually creates the following XML:\n\n<timesheet>\n<employee>\n<name>\n<forename>val1</forname>\n<surname>val2</surname>\n<title>val3></title>\n</name>\n<department>val4</department>\n</employee>\n</timesheet>\n\nConfusing eh? Far better to say:\n\n/timesheet/employee/name/forename\n/timesheet/employee/name/surname\n/timesheet/employee/name/title\n/timesheet/employee/department\n\nOr alternatively, better still:\n\n/timesheet/employee/name (Make hidden and no value)\nforename\nsurname\ntitle\n../department\n\nAttributes go in square brackets. Attribute names are preceded with an \"@\", and attribute values\nfollow an \"=\" sign and are enclosed in quotes. Multiple attributes are separated with \" and \".\n\n/table[@bgcolor=\"blue\" and @width=\"100%\"]/tr/td\n\nIf setting an attribute, it follows after the tag that it is associated with, after a \"/\" and\nit's name is preceded with an \"@\".\n\n/table/@bgcolor\n\nreadXML\nreadXML takes either a file handle or text as the first parameter and a list of queries\nfollowing that. The XML is searched for the queries and it returns a list of tuples that are the\nquery and the match.\n\nIt's easier to demonstrate this with an example. Given the following XML:\n\n<a>Foo\n<b>Bar\n<c>Fred</c>\n<c>Blogs</c>\n</b>\n<b>Red\n<c>Barbara</c>\n<c>Cartland</c>\n</b>\n<d>Food</d>\n</a>\n\nAnd the following queries:\n\n/a\n/a/b*\nc*\n/a/d\n\nit returns the following result as a list:\n\n/a\nFoo\n/a/b\nBar\nc\nFred\nc\nBlogs\n/a/b\nRed\nc\nBarbara\nc\nCartland\n/a/d\nFood\n\n(NB: This is slightly incorrect - for /a and /a/b it will return \"Foo\\n \" and \"Bar\\n \"\nrespectively).\n\nThe queries support relative paths like toXML (including parent paths), and they also support\nwildcards using \".*\" or \".*?\" (preferably \".*?\" as it's probably a better match). If a wildcard\nis specified the results will have the actual value substituted with the wildcard. Wildcards are\na bit experimental, so be careful ;-)\n",
                "subsections": [
                    {
                        "name": "Caveats",
                        "content": "There are a few caveats to using this module:\n\n*   Parameters must be on the form in the order they will appear in the XML.\n\n*   There is no support for multiple attribute setting (i.e. you can only set one attribute for\nan element at a time).\n\n*   You can't set an attribute and a value for that element, it's one or the other.\n\n*   You can use this module in place of CGI.pm, since it's a subclass.\n\n*   There are bound to be lots of bugs! Although it's in production use right now - just watch\nCPAN for regular updates.\n"
                    }
                ]
            },
            "AUTHOR": {
                "content": "Matt Sergeant msergeant@ndirect.co.uk, sergeant@geocities.com\n\nBased on an original concept, and discussions with, Jonathan Eisenzopf. Thanks to the Perl-XML\nmailing list for suggesting the XSL syntax.\n\nSpecial thanks to Francois Belanger (francois@sitepak.com) for his mentoring and help with the\nsyntax design.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "CGI(1), CGI::XML\n",
                "subsections": []
            }
        }
    }
}