
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Xml-mapping is an easy to use, extensible library that allows you to semi-automatically map Ruby objects to XML trees and vice versa.
<?xml version="1.0" encoding="ISO-8859-1"?>
<item reference="RF-0001">
<Description>Stuffed Penguin</Description>
<Quantity>10</Quantity>
<UnitPrice>8.95</UnitPrice>
</item>
class Item
include XML::Mapping
text_node :ref, "@reference"
text_node :descr, "Description"
numeric_node :quantity, "Quantity"
numeric_node :unit_price, "UnitPrice"
def total_price
quantity*unit_price
end
end
i = Item.load_from_file("item.xml")
=> #<Item:0xb7888c90 @ref="RF-0001" @quantity=10, @descr="Stuffed Penguin", @unit_price=8.95>
i.unit_price = 42.23
xml=i.save_to_xml #convert to REXML node; there's also o.save_to_file(name)
xml.write($stdout,2)
<item reference="RF-0001">
<Description>Stuffed Penguin</Description>
<Quantity>10</Quantity>
<UnitPrice>42.23</UnitPrice>
</item>
This is the most trivial example -- the mapper supports arbitrary array and hash (map) nodes, object (reference) nodes and arrays/hashes of those, polymorphic mappings, multiple mappings per class, fully programmable mappings and arbitrary user-defined node types. Read the project documentation for more information.
FAQs
Unknown package
We found that xml-mapping demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.