How to stop xmlslurper to add "<?xml version="1.0" encoding="UTF-8"?>" automatically - xml-parsing

getting that extra node "" while writing a node in XML with xmlsluper.
Got the thread response to use xmlparser.
But we do have a constraint to use xmlxlurper, how can we fix it (or remove it) with xmlslurper ?
Our groovy code snippet
def xmlFromFile = new File(xxx.xml)
def envelopeNode = new XmlSlurper( false, false ).parseText(xmlFromFile.getText())
def newNode = new XmlSlurper().parseText(SomeStringWithProperXMLChildNode)
envelopeNode.rows.appendNode(newNode)
XmlUtil xmlUtil = new XmlUtil()
xmlUtil.serialize(envelopeNode, new FileWriter(xmlFromFile))
How I can remove ""
Or can stop serialize/XmlSlurper from adding that extra encoding info.
XML Snippet :
<SomeThing xmlns="http://xmlns.oracle.com/something" name="something">
<description />
<columns>
<column name="name" />
<column name="Type" />
<column name="Identifier" />
</columns>
<rows>
<row>
<cell>111</cell>
<cell>222</cell>
<cell>333</cell>
</row>
<row>
<cell>444</cell>
<cell>555</cell>
<cell>666</cell>
</row>
</rows>
</SomeThing>
Thanks

Related

Binding Item data to the Detail View

This is my View Page
SecondView.view.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form" xmlns:anubhav="myfiori.controls" xmlns:html="http://www.w3.org/1999/xhtml" controllerName="myfiori.controller.SecondView">
<Page title="My Second View" showNavButton="true" navButtonPress="onBack" content="{/ZPO_HEADERSet}">
<content>
<Table id="lineItemsList" width="auto" items="{toItems}">
<headerToolbar>
<Toolbar id="lineItemsToolbar">
<Title id="lineItemsHeader" />
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Doc No" />
</Column>
<Column >
<Text text="Material No"/>
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
<Text text="{Ebelp}"/>
<Text text="{Matnr}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
My Item data path is "ZPO_HEADERSet('1100000001’)".so that I will get all the Items for the particular Header Id.
My controller
SecondView.controller.js
sPath = "/ZPO_HEADERSet('" + Id + "')";
this.getView().bindElement(sPath);
On pressing the Master Row, I should get it's items. But I'm getting all Item rows of every Header Id as shown in below screenshot.
This is because in your Page you are binding the whole entity set to the content aggregation.
Delete this content="{/ZPO_HEADERSet}" and try again.
The bindElement(sPath) function will prefix all your relative bindings with the 'sPath'

SAPUI5 Smart table expand

Using the publicly available Nortwhind oData v2 service I can expand on Product and Supplier entity in a normal sap.m.Table using the following code:
<Table
id="table"
width="auto"
class="sapUiResponsiveMargin"
items="{
path: '/Products',
parameters : { expand: 'Supplier' }
}">
<columns>
<Column id="nameColumn">
<Text
text="{i18n>tableNameColumnTitle}"
id="nameColumnTitle" />
</Column>
<Column hAlign="End">
<Text text="test" />
</Column>
</columns>
<items>
<ColumnListItem
type="Navigation"
press="onPress">
<cells>
<ObjectIdentifier title="{ProductName}"/>
<Text text="{Supplier/CompanyName}"/>
</cells>
</ColumnListItem>
</items>
</Table>
Now how can I achieve the same output using a smart table? Based on this post I tried the following:
<sap.ui.comp.smarttable:SmartTable
xmlns:sap.ui.comp.smarttable="sap.ui.comp.smarttable"
tableType="ResponsiveTable"
header="Smart Table"
enableAutoBinding="true"
entitySet="Products"
initiallyVisibleFields="ProductName"
tableBindingPath="Supplier"/>
But it is not working. Any suggestions?
I have moved a step further. I have added the following code:
onBeforeRebind: function(oEvent) { var mBindingParams = oEvent.getParameter("bindingParams");
mBindingParams.parameters["expand"] = "Supplier"; },
well that's it for how using $expand on Smarttables
Is there any way to display columns from the other entity?
Only via NavigationProperty. You need to extend your smarttable columns like mentioned bellow:
<smartTable:SmartTable
entitySet="Products"
tableType="ResponsiveTable"
header="Products" showRowCount="true"
enableAutoBinding="true"
class="sapUiResponsiveContentPadding">
<Table>
<columns>
<Column width="100px" hAlign="Left">
<customData>
<core:CustomData key="p13nData"
value='\{"columnKey": "p13nDataKey", "columnIndex":"4", "leadingProperty": "Supplier"}' />
</customData>
<Text text="{/#Supplier/Name/#sap:label}" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text
text="{Supplier/Name}" />
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
I have moved a step further. I have added the following code:
onBeforeRebind: function(oEvent) {
var mBindingParams = oEvent.getParameter("bindingParams");
mBindingParams.parameters["expand"] = "Supplier";
},
which kicks on beforeRebindTable event. It triggers the get expanded entity set in the backend. The problem is that I still can only see columns from the first entity as it is specified in the entitySet parameter. Is there any way to display columns from the other entity?

Why destructor of an extended binding is not called when extending binding is removed?

Creating a XulRunner application for Windows I found that if binding B extends binding A. And B is being removed, then only destructor of B is called, not followed by a call of A's destructor.
Is there something wrong with my code, or this is a XulRunner bug (I haven't find matching bug in bugzilla)?
Here is an example that I tested on XulRunner 23 and 35:
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<!--<binding-a id="A" style="-moz-binding: url('binding.xml#binding-a')"/>-->
<binding-b id="B" style="-moz-binding: url('binding.xml#binding-b')"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
binding.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("A.destructor");
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("B.destructor");
]]></destructor>
</implementation>
</binding>
</bindings>
here is the solution for your problem:
bindings.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
<method name="destruct">
<body><![CDATA[
window.print("A.destructor");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="destruct">
<body><![CDATA[
this.__proto__.__proto__.destruct.call(this);
window.print("B.destructor");
]]></body>
</method>
</implementation>
</binding>
</bindings>
bindings.css:
#namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
binding-a { -moz-binding: url("bindings.xml#binding-a"); }
binding-b { -moz-binding: url("bindings.xml#binding-b"); }
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="bindings.css" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<binding-a id="A"/>
<binding-b id="B"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
I know that it is a hack in fact but it works.

How do I get an attribute using the 'amazon-ecs' gem?

I am using Amazon Product Advertising API (amazon-ecs) gem, but I am using the item_lookup method instead of item_search, which is the only one documented.
I am looking to return the item TradeInValue but I am confused as to how to do that. It is clearly being returned, but I am not sure how to parse it.
This is the call:
Amazon::Ecs.item_lookup('9780521153348', :response_group => 'ItemAttributes', :id_type => 'ISBN', :search_index => 'Books')
And this is the return, which I am not sure what to do with. The methods in amazon-ecs don't seem to work for item_lookup and XPath isn't working either:
#<Amazon::Ecs::Response:0x007ff3325250d0 #doc=#<Nokogiri::XML::Document:0x3ff9992927a0 name="document" children=[#<Nokogiri::XML::Element:0x3ff997067414 name="ItemLookupResponse" children=[#<Nokogiri::XML::Element:0x3ff99706b924 name="OperationRequest" children=[#<Nokogiri::XML::Element:0x3ff99706b474 name="HTTPHeaders" children=[#<Nokogiri::XML::Element:0x3ff99706f470 name="Header" attributes=[#<Nokogiri::XML::Attr:0x3ff99706f0ec name="Name" value="UserAgent">, #<Nokogiri::XML::Attr:0x3ff99706f074 name="Value" value="Ruby">]>]>, #<Nokogiri::XML::Element:0x3ff9970760cc name="RequestId" children=[#<Nokogiri::XML::Text:0x3ff999296468 "053626d3-e3cd-47d2-bc8b-7ac6a0c5f6d2">]>, #<Nokogiri::XML::Element:0x3ff99929f6f8 name="Arguments" children=[#<Nokogiri::XML::Element:0x3ff9992a3bb8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992a3960 name="Name" value="Operation">, #<Nokogiri::XML::Attr:0x3ff9992a3938 name="Value" value="ItemLookup">]>, #<Nokogiri::XML::Element:0x3ff9992a73f8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992a7204 name="Name" value="Signature">, #<Nokogiri::XML::Attr:0x3ff9992a7010 name="Value" value="IMd3D0DGgAcaLR6XcuObzdAgFbOya7mbIRtZFbNijVA=">]>, #<Nokogiri::XML::Element:0x3ff9992ab41c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992ab2dc name="Name" value="AssociateTag">, #<Nokogiri::XML::Attr:0x3ff9992ab2c8 name="Value" value="textscom-20">]>, #<Nokogiri::XML::Element:0x3ff9992af774 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992af6ac name="Name" value="ItemId">, #<Nokogiri::XML::Attr:0x3ff9992af698 name="Value" value="9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9992b0c3c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b0b4c name="Name" value="IdType">, #<Nokogiri::XML::Attr:0x3ff9992b0b10 name="Value" value="ISBN">]>, #<Nokogiri::XML::Element:0x3ff9992b7794 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b7578 name="Name" value="AWSAccessKeyId">, #<Nokogiri::XML::Attr:0x3ff9992b7550 name="Value" value="AKIAJLOCEGWTFXZKXLEQ">]>, #<Nokogiri::XML::Element:0x3ff9992b2244 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b208c name="Name" value="Timestamp">, #<Nokogiri::XML::Attr:0x3ff9992b2064 name="Value" value="2013-05-07T17:46:35Z">]>, #<Nokogiri::XML::Element:0x3ff9992bffc0 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992bff20 name="Name" value="ResponseGroup">, #<Nokogiri::XML::Attr:0x3ff9992bff0c name="Value" value="ItemAttributes">]>, #<Nokogiri::XML::Element:0x3ff9992be1e8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992c38c8 name="Name" value="SearchIndex">, #<Nokogiri::XML::Attr:0x3ff9992c3a30 name="Value" value="Books">]>, #<Nokogiri::XML::Element:0x3ff9992ca95c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992ca344 name="Name" value="Service">, #<Nokogiri::XML::Attr:0x3ff9992ca2a4 name="Value" value="AWSECommerceService">]>]>, #<Nokogiri::XML::Element:0x3ff9992d3d7c name="RequestProcessingTime" children=[#<Nokogiri::XML::Text:0x3ff9992d382c "0.0289960000000000">]>]>, #<Nokogiri::XML::Element:0x3ff9992d7eb8 name="Items" children=[#<Nokogiri::XML::Element:0x3ff9992d7148 name="Request" children=[#<Nokogiri::XML::Element:0x3ff9992d6900 name="IsValid" children=[#<Nokogiri::XML::Text:0x3ff9992dae10 "True">]>, #<Nokogiri::XML::Element:0x3ff9992da758 name="ItemLookupRequest" children=[#<Nokogiri::XML::Element:0x3ff9992df884 name="IdType" children=[#<Nokogiri::XML::Text:0x3ff9992df014 "ISBN">]>, #<Nokogiri::XML::Element:0x3ff9992de678 name="ItemId" children=[#<Nokogiri::XML::Text:0x3ff9992e2e1c "9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9983a5580 name="ResponseGroup" children=[#<Nokogiri::XML::Text:0x3ff9983a59b8 "ItemAttributes">]>, #<Nokogiri::XML::Element:0x3ff9983a510c name="SearchIndex" children=[#<Nokogiri::XML::Text:0x3ff9983a43c4 "Books">]>, #<Nokogiri::XML::Element:0x3ff9983a925c name="VariationPage" children=[#<Nokogiri::XML::Text:0x3ff9983a8d0c "All">]>]>]>, #<Nokogiri::XML::Element:0x3ff9983a8244 name="Item" children=[#<Nokogiri::XML::Element:0x3ff9983add70 name="ASIN" children=[#<Nokogiri::XML::Text:0x3ff9983ad6f4 "0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983acc04 name="DetailPageURL" children=[#<Nokogiri::XML::Text:0x3ff9983ac4d4 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983b1768 name="ItemLinks" children=[#<Nokogiri::XML::Element:0x3ff9983b1024 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b0a20 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b028c "Technical Details">]>, #<Nokogiri::XML::Element:0x3ff9983b5b60 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b5638 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/tech-data/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983b5034 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b4a58 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b46d4 "Add To Baby Registry">]>, #<Nokogiri::XML::Element:0x3ff9983b406c name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b9ad0 "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983b95d0 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b9080 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b8cd4 "Add To Wedding Registry">]>, #<Nokogiri::XML::Element:0x3ff9983b8a2c name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b834c "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983bcff0 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983bc49c name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983bc0f0 "Add To Wishlist">]>, #<Nokogiri::XML::Element:0x3ff9983c1b40 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983c158c "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983c01dc name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983c5da8 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983c595c "Tell A Friend">]>, #<Nokogiri::XML::Element:0x3ff9983c5358 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983c4674 "http://www.amazon.com/gp/pdp/taf/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983c9750 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983c8828 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983cc888 "All Customer Reviews">]>, #<Nokogiri::XML::Element:0x3ff9983d1f18 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983d19c8 "http://www.amazon.com/review/product/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983d152c name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983d107c name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983d02d0 "All Offers">]>, #<Nokogiri::XML::Element:0x3ff9983d5730 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983d4e48 "http://www.amazon.com/gp/offer-listing/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>]>, #<Nokogiri::XML::Element:0x3ff9983dd00c name="ItemAttributes" children=[#<Nokogiri::XML::Element:0x3ff9983dc33c name="Author" children=[#<Nokogiri::XML::Text:0x3ff9983e1364 "Ronald L. Meek">]>, #<Nokogiri::XML::Element:0x3ff9983e0af4 name="Binding" children=[#<Nokogiri::XML::Text:0x3ff9983e04a0 "Paperback">]>, #<Nokogiri::XML::Element:0x3ff9983e0068 name="EAN" children=[#<Nokogiri::XML::Text:0x3ff9983e5c34 "9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9983e5270 name="EANList" children=[#<Nokogiri::XML::Element:0x3ff9983e4424 name="EANListElement" children=[#<Nokogiri::XML::Text:0x3ff9983d7c60 "9780521153348">]>]>, #<Nokogiri::XML::Element:0x3ff9983d7724 name="ISBN" children=[#<Nokogiri::XML::Text:0x3ff9983d7120 "0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983d6cc0 name="IsEligibleForTradeIn" children=[#<Nokogiri::XML::Text:0x3ff9983d6130 "1">]>, #<Nokogiri::XML::Element:0x3ff9983d99c0 name="ItemDimensions" children=[#<Nokogiri::XML::Element:0x3ff9983d963c name="Height" attributes=[#<Nokogiri::XML::Attr:0x3ff9983d959c name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983d83cc "902">]>, #<Nokogiri::XML::Element:0x3ff9983ed7a4 name="Length" attributes=[#<Nokogiri::XML::Attr:0x3ff9983ed448 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983f3244 "598">]>, #<Nokogiri::XML::Element:0x3ff9983f290c name="Weight" attributes=[#<Nokogiri::XML::Attr:0x3ff9983f26f0 name="Units" value="hundredths-pounds">] children=[#<Nokogiri::XML::Text:0x3ff9983e93c0 "64">]>, #<Nokogiri::XML::Element:0x3ff9983e8f38 name="Width" attributes=[#<Nokogiri::XML::Attr:0x3ff9983e8e34 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983efa2c "43">]>]>, #<Nokogiri::XML::Element:0x3ff9983ef144 name="Label" children=[#<Nokogiri::XML::Text:0x3ff9983eecbc "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9983ee988 name="Languages" children=[#<Nokogiri::XML::Element:0x3ff9983ee410 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a80009c name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a801a14 "English">]>, #<Nokogiri::XML::Element:0x3ff99a8010f0 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a800948 "Unknown">]>]>, #<Nokogiri::XML::Element:0x3ff99a800574 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a8002b8 name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a80419c "English">]>, #<Nokogiri::XML::Element:0x3ff99a805484 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a804b10 "Original Language">]>]>, #<Nokogiri::XML::Element:0x3ff99a804070 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a808d64 name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a80d6d4 "English">]>, #<Nokogiri::XML::Element:0x3ff99a80c680 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a8110a4 "Published">]>]>]>, #<Nokogiri::XML::Element:0x3ff99a8157a8 name="ListPrice" children=[#<Nokogiri::XML::Element:0x3ff99a8142cc name="Amount" children=[#<Nokogiri::XML::Text:0x3ff99a819358 "2899">]>, #<Nokogiri::XML::Element:0x3ff99a818d04 name="CurrencyCode" children=[#<Nokogiri::XML::Text:0x3ff99a818764 "USD">]>, #<Nokogiri::XML::Element:0x3ff99a81c8a0 name="FormattedPrice" children=[#<Nokogiri::XML::Text:0x3ff99a81d534 "$28.99">]>]>, #<Nokogiri::XML::Element:0x3ff99a81ccb0 name="Manufacturer" children=[#<Nokogiri::XML::Text:0x3ff99a81c648 "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff99a81c2d8 name="NumberOfItems" children=[#<Nokogiri::XML::Text:0x3ff99a821cec "1">]>, #<Nokogiri::XML::Element:0x3ff99a821580 name="NumberOfPages" children=[#<Nokogiri::XML::Text:0x3ff99a82043c "194">]>, #<Nokogiri::XML::Element:0x3ff99a825bbc name="PackageDimensions" children=[#<Nokogiri::XML::Element:0x3ff99a824cd0 name="Height" attributes=[#<Nokogiri::XML::Attr:0x3ff99a824b68 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff99a824168 "63">]>, #<Nokogiri::XML::Element:0x3ff99a829d98 name="Length" attributes=[#<Nokogiri::XML::Attr:0x3ff99a829d20 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff99a828eac "890">]>, #<Nokogiri::XML::Element:0x3ff99a828c68 name="Weight" attributes=[#<Nokogiri::XML::Attr:0x3ff99a828b8c name="Units" value="hundredths-pounds">] children=[#<Nokogiri::XML::Text:0x3ff99a828074 "66">]>, #<Nokogiri::XML::Element:0x3ff9983f69d0 name="Width" attributes=[#<Nokogiri::XML::Attr:0x3ff9983f68f4 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff997c6340c "598">]>]>, #<Nokogiri::XML::Element:0x3ff997c62cf0 name="ProductGroup" children=[#<Nokogiri::XML::Text:0x3ff997c623b8 "Book">]>, #<Nokogiri::XML::Element:0x3ff9961e1d2c name="ProductTypeName" children=[#<Nokogiri::XML::Text:0x3ff9961e0e40 "ABIS_BOOK">]>, #<Nokogiri::XML::Element:0x3ff9961e0508 name="PublicationDate" children=[#<Nokogiri::XML::Text:0x3ff9961e7b28 "2010-06-10">]>, #<Nokogiri::XML::Element:0x3ff9961e75c4 name="Publisher" children=[#<Nokogiri::XML::Text:0x3ff9961e727c "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9961e70b0 name="SKU" children=[#<Nokogiri::XML::Text:0x3ff9961e6bc4 "Y9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9961e682c name="Studio" children=[#<Nokogiri::XML::Text:0x3ff9961ebc64 "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9961ea120 name="Title" children=[#<Nokogiri::XML::Text:0x3ff996f67ac8 "Turgot on Progress, Sociology and Economics: A Philosophical Review of the Successive Advances of the Human Mind on Universal History Reflections on ... in the History and Theory of Politics)">]>, #<Nokogiri::XML::Element:0x3ff996f676cc name="TradeInValue" children=[#<Nokogiri::XML::Element:0x3ff996f67028 name="Amount" children=[#<Nokogiri::XML::Text:0x3ff996f66ca4 "310">]>, #<Nokogiri::XML::Element:0x3ff996f669d4 name="CurrencyCode" children=[#<Nokogiri::XML::Text:0x3ff996f663a8 "USD">]>, #<Nokogiri::XML::Element:0x3ff996fadbb8 name="FormattedPrice" children=[#<Nokogiri::XML::Text:0x3ff996fad014 "$3.10">]>]>]>]>]>]>]>>
Okay, I figured it out. I was trying to treat item_lookup as a single return value, rather than a hash the way search is returned.
item_lookup is basically the same as item_search:
res = Amazon::Ecs.item_lookup('9780521153348', :response_group => 'ItemAttributes', :id_type => 'ISBN', :search_index => 'Books')
res.items.each do |item|
puts item.get('ItemAttributes/TradeInValue/FormattedPrice')
end

"An item with the same key has already been added" error when calling Context AddObject

Can somebody please help me with this error. I have an ASP.NET WebApp, within the Entity Model I have an entity called tb_AdminUser, with a UserID property as GUID. This is also the Entity Key. The entity is not in any relationship with any other entity. I get the error when calling the AddObject() function.
In my code I call the following...
SQL2008R2_824852_leapdbEntities temp = new SQL2008R2_824852_leapdbEntities();
tb_AdminUser au = new tb_AdminUser();
au.UserID = Guid.NewGuid();
au.Username = "TEST";
au.Password = "pete#webinspired.net";
au.LockedOut = false;
au.Surname = "Feehan";
au.Forename = "Pete";
temp.tb_AdminUser.AddObject(au); //error occurs here
temp.SaveChanges();
The EDMX XML Code is as follows
<EntityType Name="tb_AdminUser">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="uniqueidentifier" Nullable="false" />
<Property Name="Forename" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="Surname" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="Username" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="Password" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="LockedOut" Type="bit" Nullable="false" />
</EntityType>

Resources