{"id":15732298,"url":"https://github.com/stopsopa/stopsopa-sax","last_synced_at":"2025-03-31T03:25:51.622Z","repository":{"id":57060179,"uuid":"49525369","full_name":"stopsopa/stopsopa-sax","owner":"stopsopa","description":"Lightweight SAX parser/iterator","archived":false,"fork":false,"pushed_at":"2023-09-02T00:15:54.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T08:13:06.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stopsopa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-12T19:58:44.000Z","updated_at":"2023-09-02T00:15:58.000Z","dependencies_parsed_at":"2024-10-24T23:16:41.416Z","dependency_job_id":"c9074836-6c43-46e3-890f-903a0a72978b","html_url":"https://github.com/stopsopa/stopsopa-sax","commit_stats":{"total_commits":70,"total_committers":3,"mean_commits":"23.333333333333332","dds":0.05714285714285716,"last_synced_commit":"1a57715710ac5f342ca376b15c8938afae144be4"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fstopsopa-sax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fstopsopa-sax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fstopsopa-sax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fstopsopa-sax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stopsopa","download_url":"https://codeload.github.com/stopsopa/stopsopa-sax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246409805,"owners_count":20772554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T00:08:53.492Z","updated_at":"2025-03-31T03:25:51.602Z","avatar_url":"https://github.com/stopsopa.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/stopsopa/stopsopa-sax.svg?branch=master)](https://travis-ci.org/stopsopa/stopsopa-sax)\n[![Coverage Status](https://coveralls.io/repos/stopsopa/stopsopa-sax/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/stopsopa/stopsopa-sax?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/stopsopa/sax/v/stable)](https://packagist.org/packages/stopsopa/sax)\n[![License](https://poser.pugx.org/stopsopa/sax/license)](https://packagist.org/packages/stopsopa/sax)\n\n# DEPRECATED\nCreated in 2016 - quite old now and not maintained.\n\nThat's was actually fun to implement back then.\n\n\n\u003ch1\u003estopsopa/sax\u003c/h1\u003e\n\nLightweight SAX parser/iterator\n\n\n***\n\n\n## Instalation\n\nFollow packagist instructions: [Packagist](https://packagist.org/packages/stopsopa/sax)\n\n## Usage of library: \n\n### In file mode:\n\n    use Stopsopa\\Sax\\Lib\\Sax;\n    \n    $s = new Sax($path_to_file_witch_xml_or_html, array(\n        'mode' =\u003e Sax::MODE_FILE\n    ));\n    // or\n    $s = new Sax($path_to_file_witch_xml_or_html, Sax::MODE_FILE);\n    \n    foreach ($s as $d) {\n        if ($d['type'] === Sax::N_TAG) {\n            // iterates through nodes of xml/html\n        }\n    }\n\n### In string mode:\n\n    use Stopsopa\\Sax\\Lib\\Sax;\n    \n    $s = new Sax($xml_or_html_as_a_string, array(\n        'mode' =\u003e Sax::MODE_STRING\n    ));\n    // or\n    $s = new Sax($xml_or_html_as_a_string, Sax::MODE_STRING);\n    \n    foreach ($s as $d) {\n        if ($d['type'] === Sax::N_TAG) {\n            // iterates through nodes of xml/html\n        }\n    }\n    \n## Nodes types:\n\n### Possible types with their json representation:\n\n-   Sax::N_TAG \n    \n***   \n        \n**node example** __(opening tag)__: \n    \n    \u003cnote id=\"eid\" class=\"red blue\" data-at=\"one\" data-at=\"two\" data-at\u003e\n      \n      \n**data example** __(opening tag)__:\n             \n      \n    {\n        \"type\": 2,\n        \"raw\": \"\u003cnote id=\\\"eid\\\" class=\\\"red blue\\\" data-at=\\\"one\\\" data-at=\\\"two\\\" data-at\u003e\",\n        \"data\": {\n            \"type\": \"opening\",\n            \"attr\": {\n                \"id\": \"eid\",\n                \"class\": \"red blue\",\n                \"data-at\": [\n                    \"one\",\n                    \"two\",\n                    null\n                ]\n            },\n            \"name\": \"note\"\n        },\n        \"offset\": 0\n    }\n    \n***    \n      \n**node example** __(closing tag)__: \n\n        \u003c/note\u003e\n      \n      \n**data example** __(closing tag)__: \n        \n    {\n        \"type\": 2,\n        \"raw\": \"\u003c\\/note\u003e\",\n        \"data\": {\n            \"type\": \"closing\",\n            \"name\": \"note\"\n        },\n        \"offset\": 0\n    } \n    \n***   \n      \n**node example** __(empty tag)__: \n\n    \u003cdiv data=\"empty\" /\u003e\n      \n      \n**data example** __(empty tag)__: \n\n    {\n        \"type\": 2,\n        \"raw\": \"\u003cdiv data=\\\"empty\\\" \\/\u003e\",\n        \"data\": {\n            \"type\": \"empty\",\n            \"attr\": {\n                \"data\": \"empty\"\n            },\n            \"name\": \"div\"\n        },\n        \"offset\": 0\n    }\n    \n***    \n         \n-   Sax::N_DATA   __(data between xml/html nodes)__    \n\n**data example**:  \n    \n    \u003cdiv\u003e \n    value        \n    \u003c/div\u003e\n        \n**data example**: \n \n    {\n        \"type\": 3,\n        \"raw\": \"\\r\\nvalue\\r\\n\",\n        \"offset\": 5\n    }\n \n-   Sax::N_CDATA \n\n**node example**: \n\n    \u003c![CDATA[test data]\u003e]]\u003e\n      \n      \n**data example**: \n\n    {\n        \"type\": 4,\n        \"raw\": \"\u003c![CDATA[test data]\u003e]]\u003e\",\n        \"data\": \"test data]\u003e\",\n        \"offset\": 5\n    }  \n    \n-   Sax::N_COMMENT\n\n**data example**:  \n\n    \u003c!-- comment --\u003e\n        \n**data example**: \n\n    {\n        \"type\": 5,\n        \"raw\": \"\u003c!-- comment --\u003e\",\n        \"data\": \" comment \",\n        \"offset\": 0\n    }\n  \n-   Sax::N_SPACES __(spaces between xml/html nodes)__            \n        \n**data example**:        \n        \n    {\n        \"offset\": 38, \n        \"raw\": \"\\\\r\\\\n\", \n        \"type\": 1\n    }    \n\n### Iteration:\n\n    foreach ($sax_instance as $d) {\n        switch ($d['type']) {\n            case Sax::N_TAG:\n                    // do something with decomposed tag\n                break;\n            case Sax::N_DATA:\n                    // do something with decomposed data between tag\n                break;\n            ... etc.\n        }\n    }\n\n    \n## Additional options: \n\n    $s = new Sax($pathtofile, array(\n        'encoding' =\u003e 'utf8',\n        'chunk' =\u003e null, // default 1024\n        'mode' =\u003e null // default Sax::MODE_FILE, can be also Sax::MODE_STRING\n    ));\n\n### License\n\nThe MIT License (MIT) \u003cbr /\u003e\nCopyright (c) 2016 Szymon Działowski \u003cbr /\u003e\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstopsopa%2Fstopsopa-sax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstopsopa%2Fstopsopa-sax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstopsopa%2Fstopsopa-sax/lists"}