XML is still around, and JSON is easier to work with
RSS feeds, sitemaps, product feeds for Google Merchant Center and the responses of many older banking and business systems are all written in XML. Yet most modern tools and JavaScript code handle JSON far more easily. Jood's XML to JSON converter turns those files into neatly formatted JSON you can read and use right away.
How to use it
Paste the contents of the XML file into the "Input Data" box, up to 2 MB.
Click "Start Now".
Copy the JSON with "Copy Result".
If the file has an error, such as a tag that is never closed, the tool tells you and gives the line number where it found it.
How XML structure maps to JSON
The root element becomes the first key, such as rss or urlset.
Attributes like id="101" are grouped under the @attributes key.
Text becomes the element's value directly. When an element has both attributes and text, the text goes under the #text key.
Repeated elements with the same name, like the item elements of an RSS feed, become an array in the same order.
Prefixes stay in the names, such as g:brand in Google feeds or dc:creator in WordPress feeds, and CDATA content becomes plain text.
Two practical examples
Your sitemap: open your sitemap.xml file in the browser, view the source with Ctrl+U, then copy it and paste it here. You get a list of the addresses it contains, with each page's last update date when the file includes it.
Your blog feed: the WordPress feed at /feed becomes an array of posts, each with its title, link, author and categories.
Watch out for these in your code
One element or several: in the same feed, a post with one category gives a string, while a post with two categories gives an array. Write your code to accept both.
Every value is text: a price of 249.00 stays a string rather than becoming a number, because XML does not tell the two apart. Convert it in your code when needed.
Text mixed with tags: if a paragraph has a word inside a tag, the rest of the text is gathered in #text and the word goes to a separate key, so its place in the sentence is lost. The tool suits data, not formatted documents.
An empty element becomes an empty string, and comments do not appear in the result.
For Excel tables, use the CSV to JSON converter. Your data is sent to Jood's server, converted, and not stored.
FAQ
تتحول عادة إلى حقول بأسماء مميزة، وقد يختلف الشكل بحسب المحوّل. افحص الناتج على عينة of بياناتك.
العنصر المتكرر يصبح مصفوفة، والمفرد قد يبقى كائناً. اكتب كودك ليعالج الحالتين.
غالباً XML غير سليم: وسم غير مغلق أو رمز خاص مثل & غير مهرَّب.
We use cookies to measure traffic and improve the site (Google Analytics), and may show ads later. Nothing is enabled without your consent. Privacy policy