{"id":19448045,"url":"https://github.com/scrapinghub/js2xml","last_synced_at":"2025-04-05T08:09:54.117Z","repository":{"id":16566437,"uuid":"19320322","full_name":"scrapinghub/js2xml","owner":"scrapinghub","description":"Convert Javascript code to an XML document","archived":false,"fork":false,"pushed_at":"2022-03-14T21:29:14.000Z","size":293,"stargazers_count":186,"open_issues_count":4,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T07:09:53.302Z","etag":null,"topics":["hacktoberfest","javascript","python","xml"],"latest_commit_sha":null,"homepage":"","language":"Python","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/scrapinghub.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}},"created_at":"2014-04-30T16:41:04.000Z","updated_at":"2024-06-13T03:59:14.000Z","dependencies_parsed_at":"2022-09-24T07:51:16.806Z","dependency_job_id":null,"html_url":"https://github.com/scrapinghub/js2xml","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrapinghub%2Fjs2xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrapinghub%2Fjs2xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrapinghub%2Fjs2xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrapinghub%2Fjs2xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scrapinghub","download_url":"https://codeload.github.com/scrapinghub/js2xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"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":["hacktoberfest","javascript","python","xml"],"created_at":"2024-11-10T16:23:29.117Z","updated_at":"2025-04-05T08:09:54.098Z","avatar_url":"https://github.com/scrapinghub.png","language":"Python","readme":"js2xml\n======\n\n[![Tests](https://github.com/scrapinghub/js2xml/actions/workflows/tests.yml/badge.svg)](https://github.com/scrapinghub/js2xml/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/scrapinghub/js2xml/branch/master/graph/badge.svg)](https://codecov.io/gh/scrapinghub/js2xml)\n\nConvert Javascript code to an XML document.\n\nThis makes it easy to extract data embedded in JavaScript code using XPath\nin a way more robust than just using regular expressions.\n\n\n# Install:\n\nYou can install js2xml via [PyPI](https://pypi.python.org/pypi/js2xml):\n\n    pip install js2xml\n\n\n# Example:\n\n```python\n\u003e\u003e\u003e import js2xml\n\u003e\u003e\u003e\n\u003e\u003e\u003e jscode = \"\"\"function factorial(n) {\n...     if (n === 0) {\n...         return 1;\n...     }\n...     return n * factorial(n - 1);\n... }\"\"\"\n\u003e\u003e\u003e parsed = js2xml.parse(jscode)\n\u003e\u003e\u003e\n\u003e\u003e\u003e parsed.xpath(\"//funcdecl/@name\")  # extracts function name\n['factorial']\n\u003e\u003e\u003e\n\u003e\u003e\u003e print(js2xml.pretty_print(parsed))  # pretty-print generated XML\n\u003cprogram\u003e\n  \u003cfuncdecl name=\"factorial\"\u003e\n    \u003cparameters\u003e\n      \u003cidentifier name=\"n\"/\u003e\n    \u003c/parameters\u003e\n    \u003cbody\u003e\n      \u003cif\u003e\n        \u003cpredicate\u003e\n          \u003cbinaryoperation operation=\"===\"\u003e\n            \u003cleft\u003e\n              \u003cidentifier name=\"n\"/\u003e\n            \u003c/left\u003e\n            \u003cright\u003e\n              \u003cnumber value=\"0\"/\u003e\n            \u003c/right\u003e\n          \u003c/binaryoperation\u003e\n        \u003c/predicate\u003e\n        \u003cthen\u003e\n          \u003cblock\u003e\n            \u003creturn\u003e\n              \u003cnumber value=\"1\"/\u003e\n            \u003c/return\u003e\n          \u003c/block\u003e\n        \u003c/then\u003e\n      \u003c/if\u003e\n      \u003creturn\u003e\n        \u003cbinaryoperation operation=\"*\"\u003e\n          \u003cleft\u003e\n            \u003cidentifier name=\"n\"/\u003e\n          \u003c/left\u003e\n          \u003cright\u003e\n            \u003cfunctioncall\u003e\n              \u003cfunction\u003e\n                \u003cidentifier name=\"factorial\"/\u003e\n              \u003c/function\u003e\n              \u003carguments\u003e\n                \u003cbinaryoperation operation=\"-\"\u003e\n                  \u003cleft\u003e\n                    \u003cidentifier name=\"n\"/\u003e\n                  \u003c/left\u003e\n                  \u003cright\u003e\n                    \u003cnumber value=\"1\"/\u003e\n                  \u003c/right\u003e\n                \u003c/binaryoperation\u003e\n              \u003c/arguments\u003e\n            \u003c/functioncall\u003e\n          \u003c/right\u003e\n        \u003c/binaryoperation\u003e\n      \u003c/return\u003e\n    \u003c/body\u003e\n  \u003c/funcdecl\u003e\n\u003c/program\u003e\n\n\u003e\u003e\u003e\n```\n\n\n# Changelog\n\n## v0.5.0 (2022-03-14)\n\n- Add official Python 3.9 and 3.10 support, drop Python 2.7 support, remove\n  `six` dependency\n\n- Support a class call without parameters (e.g. `new Map`)\n\n- Updated the CI setup\n\n## v0.4.0 (2020-06-04)\n\n- Add Python 3.7 and 3.8 support, drop Python 3.4 support\n\n- Use `calmjs.parse` instead of `slimit` for JavaScript parsing\n\n  [`calmjs.parse`](https://github.com/calmjs/calmjs.parse) is a well-maintained\n  fork of [`slimit`](https://github.com/rspivak/slimit) which solves some of\n  its shortcomings, such as support for JavaScript keywords being used as\n  object keys.\n\n  However, `calmjs.parse` also introduces slight changes to the output of\n  js2xml, making this change backward-incompatible.\n\n- Fix unicode surrogate pair handling\n\n- Code cleanup for Python 3\n\n## v0.3.1 (2017-08-03)\n\n- Fix packaging\n\n## v0.3.0 (2017-08-03)\n\n- Add Python 3.6 support\n- Deprecate `js2xml.jsonlike`\n- Introduce `js2xml.utils.objects` module:\n\n  - `js2xml.utils.objects.make(node)`: takes a node in the js2xml-parsed\n    tree and converts to a suitable Python object\n  - `js2xml.utils.objects.findall(tree, types)`: used to find the\n    top-most nodes in the js2xml-parsed tree that can be converted to\n    a `dict`, `list`, `str`, `bool`, `int` or `float`\n  - `js2xml.utils.objects.getall(tree, types)`: same as `.findall()`\n    except that it converts what was found to the corresponding Python\n    object, using `js2xml.utils.objects.make()`\n\n- Introduce `js2xml.utils.vars` module:\n\n  - `js2xml.utils.vars.get_vars(tree)` can be used to turn a JS snippet\n    into a python object where you can access JavaScript variables\n    by name and get the parsed values\n\n## v0.2.3 (2017-05-30)\n\n- Regenerate lextab.py and yacctab.py files with PLY 3.10\n- Properly set logger level to ERROR\n\n## v0.2.2 (2016-12-01)\n\n- Include lextab.py and yacctab.py files to (hopefully) remove write\n  permission warnings (see issue #16)\n- Run tests with tox (locally and on Travis CI)\n- Add code coverage reports (+ codecov.io for Travis CI builds)\n- Run tests with Python 3.6\n- Automatic PyPI deploys from Travis CI\n\n## v0.2.1 (2016-06-10)\n\n- Distribute as universal wheel\n\n## v0.2.0 (2016-06-10)\n\n- Python 3 support (tested with 3.4 and 3.5)\n- Use logger to suppress Yacc warnings\n- require PLY \u003e 3.6\n- Use bumpversion for versioning\n- Pretty-print output is now a Unicode string\n\n## v0.1.2 (2015-05-11)\n\n- Profiling scripts added\n- Updated notes with use-case, installing via pip\n- Force PLY 3.4 (3.6 has issues with slimit)\n\n## v0.1.1 (2014-08-13)\n\n- Fix parsing of objects with integer keys\n- Fix try/catch/finally and named function expressions\n- Add download URL in setup file (for PyPI)\n\n## v0.1 (2014-08-12)\n\nInitial release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrapinghub%2Fjs2xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrapinghub%2Fjs2xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrapinghub%2Fjs2xml/lists"}