Sha256: 3fc69da3eb72fa0b94cde98a9a60b9ed9a88663df3ca3ed34044d7293b210c41

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

module ZCI

  def parse_category_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    category_xml = doc.xpath("//category").first

    category = {
      id: category_xml[:id],
      name: category_xml.xpath('name').text,
      description: category_xml.xpath('description').text,
      position: category_xml[:position],
    }

    return category
  end

  def parse_section_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    section_xml = doc.xpath("//section").first

    section = {
      id: section_xml[:id],
      category_id: section_xml[:category_id],
      name: section_xml.xpath('name').text,
      description: section_xml.xpath('description').text,
      position: section_xml[:position],
    }

    return section
  end

  def parse_article_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    article_xml = doc.xpath('//article').first

    article = {
      id: article_xml[:id],
      section_id: article_xml[:section_id],
      title: article_xml.xpath('title').text,
      body: article_xml.xpath('body').text,
      position: article_xml[:position],
    }

    return article
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
zci-0.9.0 lib/zci/export.rb
zci-0.8.0 lib/zci/export.rb
zci-0.7.2 lib/zci/export.rb
zci-0.7.1 lib/zci/export.rb
zci-0.7.0 lib/zci/export.rb
zci-0.6.1 lib/zci/export.rb
zci-0.6.0 lib/zci/export.rb
zci-0.5.0 lib/zci/export.rb
zci-0.4.0 lib/zci/export.rb
zci-0.3.1 lib/zci/export.rb
zci-0.3.0 lib/zci/export.rb
zci-0.2.0 lib/zci/export.rb
zci-0.1.2 lib/zci/export.rb
zci-0.1.1 lib/zci/export.rb
zci-0.1.0 lib/zci/export.rb