문제

My xml file is this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
      <key>items</key>
      <array>
          <dict>
              <key>assets</key>
              <array>
                  <dict>
                      <key>kind</key>
                      <string>software-package</string>
                      <key>url</key>
                      <string>http://172.16.147.75:3000/testfile/TestInstall.ipa</string>
                  </dict>
              </array>
              <key>metadata</key>
              <dict>
                  <key>bundle-identifier</key>
                  <string>MainStoryboard_iPad</string>
                  <key>bundle-version</key>
                  <string>1.0</string>
                  <key>kind</key>
                  <string>software</string>
                  <key>title</key>
                  <string>TestInstall</string>
              </dict>
          </dict>
      </array>
  </dict>
</plist>

and i want to generate this file using nokogiri or any other method or gem please someone help me.

도움이 되었습니까?

해결책

Ofcourse you can use the nokogiri builder as recommended byBaldrick

and to generate xml output to the file you can do:

xml_file = open(filename, 'w')
xml_file.write xml_string
xml_file.close

Or using the block syntax to achieve this in one line:

File.open(local_filename, 'w') { |f| f.write(xml_string) }

다른 팁

Try this :

Below link provide you how to generate xml using nokogiri.

http://runnable.com/UjY9hE5ZnwIjAAED/how-to-create-xml-with-nokogiri-for-ruby-on-rails-and-csv

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top