Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:57:20+00:00 2026-06-09T22:57:20+00:00

Basically questions says it all, how can I convert an xml file to yaml?

  • 0

Basically questions says it all, how can I convert an xml file to yaml?

I’ve tried this:

require 'active_support/core_ext/hash/conversions'
require 'yaml'

file = File.open("data/mconvert.xml", "r")
hash = Hash.from_xml(file.read)
yaml = hash.to_yaml
File.open("data/mirador.yml", "w") { |file| file.write(yaml) }

But, I am getting an “Exception parsing” error. I thought that was because I had dashes in an xml tag name, so I replaced the dashes with dashcharacterr But that still didn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:57:21+00:00Added an answer on June 9, 2026 at 10:57 pm

    If we have a look at the XML 1.0 specification, we’ll see that start tags look like this:

    [40]    STag ::= '<' Name (S Attribute)* S? '>'
    

    and then elsewhere, we find the definition of Name:

    [4]     NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
    [4a]    NameChar      ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
    

    You’ll notice that - is not in NameStartChar so this:

    <-vikings->1336162202</-vikings->
    

    is not valid XML and this part of your code:

    hash = Hash.from_xml(file.read)
    

    is failing because your file doesn’t contain XML, it contains text that looks like XML but isn’t quite real XML.

    Fix your data/mconvert.xml file to contain real XML and try again.


    If you try a simple experiment in the Rails console, you’ll see what’s going on:

    > Hash.from_xml('<-vikings->1336162202</-vikings->')
    REXML::ParseException: #<REXML::ParseException: malformed XML: missing tag start
    Line: 1
    Position: 33
    Last 80 unconsumed characters:
    <-vikings->1336162202</-vikings->>
    

    notice the “malformed XML: missing tag start”?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title basically says it all. I'm aware this can't be done using traditional
My question basically says it all. I am getting this: C:\DOCUME~1\frew\MYDOCU~1\Code\AIRCRA~1\lib\ACD\VALIDA~1.PM and I want
Basically, the question says it all. I need a PL\SQL query that returns a
I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
The question title basically says it all. Is it possible in JPA/Hibernate to gracefully
So yeah, the question basically says it all. What do you gain when you
The question basically says it all. I want to be able to get a
Question pretty much says it all. You can read entity association here , but
The question says it all basically. I want in a class MyClass to listen
The title basically says it all. I need to determine the Windows Service Pack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.