{"id":25011428,"url":"https://github.com/aknopov/xml-comparator","last_synced_at":"2025-03-30T03:16:37.274Z","repository":{"id":269874659,"uuid":"908717546","full_name":"aknopov/xml-comparator","owner":"aknopov","description":"GoLang library for comparing XML strings","archived":false,"fork":false,"pushed_at":"2025-01-31T16:05:23.000Z","size":79,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T17:20:27.112Z","etag":null,"topics":["comparison","golang","library","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","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/aknopov.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":"2024-12-26T19:20:55.000Z","updated_at":"2025-01-31T16:05:26.000Z","dependencies_parsed_at":"2025-01-19T21:31:38.029Z","dependency_job_id":"d457ff68-e081-47f8-87e7-9921b9703186","html_url":"https://github.com/aknopov/xml-comparator","commit_stats":null,"previous_names":["aknopov/xmlcomparator","aknopov/xml-comparator"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aknopov%2Fxml-comparator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aknopov%2Fxml-comparator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aknopov%2Fxml-comparator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aknopov%2Fxml-comparator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aknopov","download_url":"https://codeload.github.com/aknopov/xml-comparator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246269928,"owners_count":20750321,"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":["comparison","golang","library","xml"],"created_at":"2025-02-05T05:31:22.380Z","updated_at":"2025-03-30T03:16:37.256Z","avatar_url":"https://github.com/aknopov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/aknopov/xml-comparator/go.yml)\n![Coveralls](https://img.shields.io/coverallsCoverage/github/aknopov/xml-comparator)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Go Reference](https://pkg.go.dev/badge/google.golang.org/xmlcomparator.svg)](https://pkg.go.dev/github.com/aknopov/xmlcomparator)\n\n# XmlComparator\n\nGoLang library for comparing XML strings\n\n## Overview\n\nAPI consists of two functions - \n```\nxmlcomparator.CompareXmlStrings(sample1 string, sample2 string, stopOnFirst bool) []string\nxmlcomparator.CompareXmlStringsEx(sample1 string, sample2 string, stopOnFirst bool, ignored []string) []string\n```\nthat return a list of detected differences between two XML samples. Comparison can be stopped on the first occasion - `stopOnFirst=true`. The second form takes a list of RegEx strings to be used as a filter for ignored differences.\n\nEach entry in the returned list contains the XML path to the node like  `..., path='/note/to[0]'`. Path elements might contain zero-based index of an element in the siblings list.\n\nWhen a difference in children elements is detected, the message has the form `Children differ: counts 3 vs 4: ...` where the first number is the count of children in the first sample.\nMismatched child elements in the `diffs` list have two numbers. The first, in square brackets, is the index in the sibling nodes list.\nThe second - suffix like `:+1` or `:-3` is the count of consecutive mismatched elements with the same name. A positive number relates to the count of elements in `sample1`, negative - to `sample2`.\n\nExample of usage in the code -\n```go\n    import (\n        \"github.com/aknopov/xmlcomparator\"\n    )\n\n    ...\n    xmlSample1 := \"\u003ca\u003e\u003cb/\u003e\u003cc/\u003e\u003c/a\u003e\"\n    xmlSample2 := \"\u003ca\u003e\u003cc/\u003e\u003cb/\u003e\u003c/a\u003e\"\n    diffs := xmlcomparator.CompareXmlStrings(xmlSample1, xmlSample2, false)\n    assert.Equal([]string{\"Children order differ for 2 nodes, path='/a'\"},\n        CompareXmlStrings(xmlSample1, xmlSample2, true))\n\n    xmlSample3 := `\u003ca\u003e\u003cb\u003e\u003cc/\u003e\u003cc/\u003e\u003cd/\u003e\u003c/b\u003e\u003c/a\u003e`\n    xmlSample4 := `\u003ca\u003e\u003cb\u003e\u003cd/\u003e\u003ce/\u003e\u003ce/\u003e\u003ce/\u003e\u003c/b\u003e\u003c/a\u003e`\n    assert.Equal([]string{\"Children differ: counts 3 vs 4: c[0]:+2, e[1]:-3, path='/a/b'\"}, CompareXmlStrings(xmlSample3, xmlSample4, false))\n\n    diffs := CompareXmlStringsEx(xmlString1, xmlMixed, false, []string{`Node texts differ: '.+' vs '.+'`})\n    assert.Equal(1, len(diffs))\n\n    xmlString5 := `\u003ca\u003eNode Content\u003c/a\u003e`\n    xmlString6 := `\u003ca\u003eAnother Content\u003c/a\u003e`\n    diffs = CompareXmlStringsEx(xmlString5, xmlString6, false, []string{`Node textsNodes test differ: '.+' vs '.+'`})\n    assert.Equal(0, len(diffs))\n\n    // To get more insite\n    recorder := ComputeDifferences(xmlString1, xmlMixed, false, []string{})\n    assert.Equal(3, len(recorder.Diffs))\n    assert.Equal(DiffContent, recorder.Diffs[0].GetType())\n    assert.Equal(\"Node texts differ: 'Jani' vs 'Tove', path='/note/from[1]'\", recorder.Diffs[0].DescribeDiff())\n    assert.Equal(\"/note/from[1]\", recorder.Diffs[0].XmlPath())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faknopov%2Fxml-comparator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faknopov%2Fxml-comparator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faknopov%2Fxml-comparator/lists"}