Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


xml_file (2) Versions 0.1.0

Provides xml_file resource-provider

cookbook 'xml_file', '= 0.1.0', :supermarket
cookbook 'xml_file', '= 0.1.0'
knife supermarket install xml_file
knife supermarket download xml_file
Quality 0%

xml_file - Cookbook

xml_file resource-provider to manage XML files.


xml_file resource allows managing XML files where only parts of the file's
content is controlled. Users can specify XPath targets and expected content
at those targets.


xml_file resource allows three different attributes to specify
partial content.

  • 'partial' attribute to add a XML fragments. Following example will insert part.xml (present in files/default directory of the consumer cookbook) at '/parent/child' XPath target's last element. whole.xml xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="git"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Morrison</maintainer> </maintainers> <project>


xml_file '/opt/whole.xml' do
  partial '//project', 'part.xml'
  owner 'root'
  group 'root'
  mode 0644

will result:
<?xml version="1.0" encoding="UTF-8"?>
<project name="">
<repo type="git"></repo>

before or after keys can be specified alongside the XPath values
to insert the elements at certain position with respective to their siblings.

  • The attribute method allows setting the value of an XML element's attribute. Following is an example: ruby xml_file '/opt/whole.xml' do attribute '//project/repo', 'type', 'svn' owner 'root' group 'root' mode 0644 end Will result: xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="svn"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Morrison</maintainer> </maintainers> <project> Finally, the text method will set the text content of an XML element. Following example: ruby xml_file '/opt/whole.xml' do text '//maintainer[last()]', 'Ray' owner 'root' group 'root' mode 0644 end will result: xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="svn"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Ray</maintainer> </maintainers> <project>

All three methods can be combined. When used in combination, partials are
processed before text and attribute, hence they can refer to XPath introduced by partials.

xml_file resource only supprts :edit action. Its written in
REXML and should be portable across platforms.


Apache 2


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

goatos Applicable Versions

Foodcritic Metric

0.1.0 failed this metric

FC023: Prefer conditional attributes: /tmp/cook/a63fa6ac9ebcb4fe54af40c9/xml_file/libraries/xml_file.rb:96