سؤال

I am writing an xml exporter in ruby and I am using libxml package for it. I want to write some comment nodes outside the root element

<?xml version="1.0" encoding="UTF-8"?>
<!-- comment -->
<root>
 <childnode />
</root>

How do I accomplish export to above format?

Sample ruby code to generate the above (without accounting for comment node)

doc = XML::Document.new()
rootNode = XML::Node.new('root')
doc.root = rootNode
childNode = XML::Node.new('childnode')
childnode << rootNode
هل كانت مفيدة؟

المحلول

ended up editing the xml string manually to add the comments outside the root node (for both libxml and nokogiri

نصائح أخرى

<?xml version="1.0" encoding="UTF-8" ?>
<List type = "" =”00:75:00” =”00:00:05”>

</List>

Yes

<?xml version="1.0" encoding="UTF-8" ?>
<List type = "update" >
</List>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top