2008-08-31から1日間の記事一覧

Xmlの操作 書き込み編

require 'rexml/document' doc = REXML::Document.new() doc << REXML::XMLDecl.new('1.0', 'UTF-8') root = doc.add_element("社員名簿") node = root.add_element("課", {"課名称" => "営業"}) name_node = REXML::Element.new("名前") name_node.attribut…

Xmlの操作 読み込み編

item.xml:これを下記コードで読み込みする。 <inventory title="OmniCorp Store #45x10^3"> <section name="health"> <item upc="123456789" stock="12"> <name>Invisibility Cream</name> <price>14.50</price> <description>Makes you invisible</description> </item> </section></inventory>