{"id":20060935,"url":"https://github.com/jcf/vtd-xml","last_synced_at":"2025-05-05T15:33:28.793Z","repository":{"id":6982205,"uuid":"8243848","full_name":"jcf/vtd-xml","owner":"jcf","description":"A fast JRuby-only XML parser","archived":false,"fork":false,"pushed_at":"2013-04-06T11:25:38.000Z","size":712,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-02T10:06:55.536Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/jcf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-17T00:34:34.000Z","updated_at":"2016-07-13T13:20:20.000Z","dependencies_parsed_at":"2022-09-16T18:41:07.085Z","dependency_job_id":null,"html_url":"https://github.com/jcf/vtd-xml","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcf%2Fvtd-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcf%2Fvtd-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcf%2Fvtd-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcf%2Fvtd-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcf","download_url":"https://codeload.github.com/jcf/vtd-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252524324,"owners_count":21762074,"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-11-13T13:17:35.328Z","updated_at":"2025-05-05T15:33:28.456Z","avatar_url":"https://github.com/jcf.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vtd-xml\n\nParse large amounts of XML quickly and easily.\n\n**This library currently only works with JRuby.**\n\n[![Build Status](https://travis-ci.org/jcf/vtd-xml.png?branch=master)](https://travis-ci.org/jcf/vtd-xml)\n[![Code Climate](https://codeclimate.com/github/jcf/vtd-xml.png)](https://codeclimate.com/github/jcf/vtd-xml)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'vtd-xml', '~\u003e 0.0.1'\n\nAnd then execute:\n\n    bundle\n\nOr install it yourself as:\n\n    gem install vtd-xml\n\n## Usage\n\nWith the following example XML:\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cbooks\u003e\n  \u003cbook title=\"A Tale of Two Cities\" sold=\"200000000\" firstPublished=\"1859\"\u003e\n    \u003cauthor name=\"Charles Dickens\" /\u003e\n    \u003clanguage\u003eEnglish\u003c/language\u003e\n    \u003cpublisher\u003eChapman \u0026amp; Hall\u003c/publisher\u003e\n    \u003cratings\u003e\n      \u003crating userID=\"1\"\u003e5\u003c/rating\u003e\n      \u003crating userID=\"4\"\u003e2\u003c/rating\u003e\n      \u003crating userID=\"2\"\u003e3\u003c/rating\u003e\n    \u003c/ratings\u003e\n  \u003c/book\u003e\n  \u003cbook title=\"The Lord of the Rings\" sold=\"150000000\" firstPublished=\"1954\"\u003e\n    \u003cauthor name=\"J. R. R. Tolkien\" /\u003e\n    \u003clanguage\u003eEnglish\u003c/language\u003e\n    \u003cpublisher\u003eGeorge Allen \u0026amp; Unwin\u003c/publisher\u003e\n    \u003cratings\u003e\n      \u003crating userID=\"1\"\u003e5\u003c/rating\u003e\n      \u003crating userID=\"4\"\u003e4\u003c/rating\u003e\n      \u003crating userID=\"2\"\u003e5\u003c/rating\u003e\n    \u003c/ratings\u003e\n  \u003c/book\u003e\n  \u003cbook title=\"The Little Prince\" sold=\"140000000\" firstPublished=\"1943\"\u003e\n    \u003cauthor name=\"Antoine de Saint-Exupéry\" /\u003e\n    \u003clanguage\u003eFrench\u003c/language\u003e\n    \u003cpublisher\u003eGallimard\u003c/publisher\u003e\n    \u003cratings\u003e\n      \u003crating userID=\"4\"\u003e4\u003c/rating\u003e\n      \u003crating userID=\"2\"\u003e2\u003c/rating\u003e\n      \u003crating userID=\"1\"\u003e3\u003c/rating\u003e\n    \u003c/ratings\u003e\n  \u003c/book\u003e\n\u003c/books\u003e\n```\n\n### Parsing a file\n\n``` ruby\nrequire 'vtd-xml'\n\n# Create a parser\nparser = VTD::Xml::Parser.new 'path/to.xml'\n\n# This shortcut does the same\nparser = VTD::Xml.open 'path/to.xml'\n\nparser.find('//book/author').each do |node|\n  # Iterates through each node\nend\n\nparser.find('//book/author').max_by { |node| node['sold'] }\n```\n\n### Finding a node\n\n``` ruby\nnode = parser.find('//book/author[1]').first\n```\n\n### Working with attributes\n\n``` ruby\n\n# Accessing attributes\nnode['name']\n\nnode.fetch('missing', 'so use this default')\nnode.fetch('another-missing') { 'so call this block and use it' }\n\nnode.slice('title', 'missing')\n# =\u003e {'title' =\u003e 'A Tale of Two Cities',  'missing' =\u003e nil}\n\nnode.attributes # =\u003e returns every attribute\n```\n\n### Node traversal\n\n``` ruby\nchild = node.children('language').first\nchild.text # =\u003e \"English\"\n\nnode.children('rating').map do |child|\n  child.text.to_i\nend\n# =\u003e [5,2,3]\n```\n\n**See the examples directory for more.**\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcf%2Fvtd-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcf%2Fvtd-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcf%2Fvtd-xml/lists"}