S
S
Semyon Semyonov2016-04-01 17:57:21
Ruby on Rails
Semyon Semyonov, 2016-04-01 17:57:21

How to add first line to Ox (xml parser)?

It's about https://github.com/ohler55/ox . Writing

doc = Ox::Document.new(:version => '1.0', :encoding => 'UTF-8', :standalone => 'yes')

waiting for the output to receive
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

But in fact it doesn’t work, but at the output I get a root element
doc = Ox::Document.new(:version => '1.0', :encoding => 'UTF-8', :standalone => 'yes')
root = Ox::Element.new('first_el')
root[:attr1] = Time.now.to_i.to_s
doc << root

...

Ox.to_file(filepath, doc, nil)

Eventually
<first_el attr1="1459522227">
...
</first_el>

How to add something
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Semyon Semyonov, 2016-04-01
@man_without_face

I decided by writing a line to a file directly, and not through to_file. Well, I added the required line to the line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question