ckruse / CFPropertyList

Read, write and manipulate both binary and XML property lists as defined by apple
MIT License
212 stars 47 forks source link

Prettify XML option? #37

Closed kenn closed 9 years ago

kenn commented 9 years ago

Generated XML has a single line with the plist.

<?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"><array><array><string>woman</string><string>female</string></array><array><string>man</string><string>male</string></array></array></plist>

Is it possible to have (indented) line feeds?

<?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">
  <array>
    <array>
      <string>woman</string>
      <string>female</string>
    </array>
    <array>
      <string>man</string>
      <string>male</string>
    </array>
  </array>
</plist>

Because it's easier to track diff on git, and also easier to browse the content on text editors / github.

ckruse commented 9 years ago

Yes you can, there is a :formatted option for the to_str and save methods:

plist.to_str(CFPropertyList::List::FORMAT_XML, :formatted => true)
plist.save('test.plist', CFPropertyList::List::FORMAT_XML, :formatted => true)
ckruse commented 9 years ago

I guess this solves your issue and thus I close it. Feel free to re-open if problems occur!