LINQ to XML and Amazon Webservices

Hi, I'm having a hard time in using LINQ on XML returned from Amazon 
Webservices.

I'm using the 2008 beta 2 on an XP machine.

the code I'm using is:

=========
        Dim s As String
        s = "http://ecs.amazonaws.com/onca/xml?" & _
                  "Service=AWSECommerceService&" & _
                  "AWSAccessKeyId=1234&" & _
                  "AssociateTag=my-tag&" & _
                  "ResponseGroup=Small&" & _
                  "Operation=ItemSearch&" & _
                  "SearchIndex=Music&" & _
                  "Keywords=neil young"
        Dim ResponseDoc As Linq.XDocument = XDocument.Load(s)
        Dim ReturnedItems = From ReturnedItem In 
ResponseDoc.Descendants("Item") _
                    Select ASIN = ReturnedItem.Element("ASIN").Value, _
                           URL = ReturnedItem.Element("DetailPageURL").Value

===========

ReturnedItems is always empty.

Am I doing something wrong?  Is Amazon XML wrong in some way?

thanks

Gil S.
-- 
They don''''t make bugs like bunny anymore
0
mudGil (2)
9/20/2007 3:06:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
720 Views

Similar Articles

[PageSpeed] 39

mudGil wrote:
> Hi, I'm having a hard time in using LINQ on XML returned from Amazon 
> Webservices.
> 
> I'm using the 2008 beta 2 on an XP machine.
> 
> the code I'm using is:
> 
> =========
>         Dim s As String
>         s = "http://ecs.amazonaws.com/onca/xml?" & _
>                   "Service=AWSECommerceService&" & _
>                   "AWSAccessKeyId=1234&" & _
>                   "AssociateTag=my-tag&" & _
>                   "ResponseGroup=Small&" & _
>                   "Operation=ItemSearch&" & _
>                   "SearchIndex=Music&" & _
>                   "Keywords=neil young"
>         Dim ResponseDoc As Linq.XDocument = XDocument.Load(s)
>         Dim ReturnedItems = From ReturnedItem In 
> ResponseDoc.Descendants("Item") _
>                     Select ASIN = ReturnedItem.Element("ASIN").Value, _
>                            URL = ReturnedItem.Element("DetailPageURL").Value
> 
> ===========
> 
> ReturnedItems is always empty.
> 
> Am I doing something wrong?  Is Amazon XML wrong in some way?

Can you show us a sample of the XML you are trying to process? As the 
web service requires an access id it is easier to help you if you 
provide the XML sample.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
9/20/2007 3:35:17 PM
mudGil wrote:

> Am I doing something wrong?  Is Amazon XML wrong in some way?

Those elements are in a namespace so one way with VB and LINQ is as 
follows, put the following two lines

Imports System.Xml.Linq
Imports 
<xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">

at the beginning of your program, then inside your program use the 
following syntax:

         Dim ResponseDoc As XDocument = XDocument.Load(s)
         Console.WriteLine(ResponseDoc.ToString())
         For Each item As XElement In ResponseDoc...<Item>
             Console.WriteLine("ASIN: {0}", item.<ASIN>.Value)
         Next


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
9/20/2007 3:57:33 PM
Hello mudGil,

Due to VS 2008 has not been final released so far, LINQ issue is not 
supported by MSDN Managed Newsgroup Team.
If you have issue related to LINQ, you may also post it in MSDN Forum,
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=123&SiteID=1
The people in those groups will be more likely to be able to help and 
familiar in such field.

If you have any more concern, please also feel free to update here. It's my 
pleasure to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-wywang (104)
9/27/2007 9:03:53 AM
WenYuan Wang [MSFT] wrote:
> Hello mudGil,
> 
> Due to VS 2008 has not been final released so far, LINQ issue is not 
> supported by MSDN Managed Newsgroup Team.
> If you have issue related to LINQ, you may also post it in MSDN Forum,
> http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=123&SiteID=1
> The people in those groups will be more likely to be able to help and 
> familiar in such field.
> 
> If you have any more concern, please also feel free to update here. It's my 
> pleasure to assist you.
> 
> Have a great day,
> Best regards,
> 
> Wen Yuan
> Microsoft Online Community Support 
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> 
Why did this happen to end up on my computer????????////
0
12/25/2007 3:08:02 AM
Reply:

Similar Artilces:

.csv File to .xml File in VB.Net using 2.0 Framework and .xsd
Hey All, I've been searching for a code snippet, not a 3rd party tool, that takes a ..csv file and transforms it to an .xml file based upon an .xsd. Can anyone point me in the right direction or provide a code snippet? I would prefer vb.net but C# is fine too or even pseudo code with appropriate .Net objects and example. Thanks, TC TC, A CSV has no XSD, and there is not even a relatieon, how did you want to do this, without a XSD it is simple, http://www.vb-tips.com/dbpages.aspx?Search=csv To make it an xml file you do simple ds.WriteXML(path) Cor "TC" <getm...

xml validation against dtd
Hello I need to validate xml files against dtd files, however the xml files I will receive will not have the correct path to the dtd on my end. The declaration in the xml is not qualified, it's just the dtd filename, so I figure I can always copy the xml file to the same directory as the dtd then read/validate the xml, however this is not an optimal solution. Can anyone tell me if it is possible to explicitly define the path to the dtd file when validating? I am currently using the XMLValidatingReader. Thanks in advance Jon HI Jon, Indeed, you can use a pre-set path. See the exampl...

Include XML data in dll
I'm writing an application where I need to store a small amount of xml data in a relatively secure way - I don't want it just sitting out there in a separate file; I'd rather have it compiled into the dll I'll produce. What's the best way to achieve this? - Turtle You can put it in resource. If you like, you can encrypt the resource. To add a resource to VS project, add the file to the project in the olution Explorer, then set the properties of the file to be an embedded resource. Paul "MacDermott" <macdermott@mindspring.com> wrote in message ...

Message Tracking XML File
Hello: Is there any utility out there that can read the XML file saved from the Message Tracking Center, and present it in an easily readable format? MS explains the XML schema at http://msdn.microsoft.com/en-us/library/ms987640(EXCHG.65).aspx but doesn't offer a program to do anything. I found http://theessentialexchange.com/blogs/michael/archive/2007/11/13/more-exchange-message-tracking.aspx, which looks like it'll take the raw log files themselves and convert them into XML, which isn't what I need. Thank you. -- Regards, M MCTS, MCSA Nevermind....

reading only the first 30 bytes of an HTML file with xml object
Hi, I wonder if there is a way to read only the first x bytes of a xml responsetext. In my project I need only first 20-30 bytes of very large HTML files and i don't want to wait for the rest to be read. Here is a piece of code i use ; Dim xml As New MSXML2.XMLHTTP xml.Open "GET", address , False xml.Send MsgBox Left(CStr(xml.responseText),25), vbInformation, "Info..." This code does the thing i want but i have to wait for all the body to be read and only after that time i can parse the text. I want to stop the process after 30. byte is read bec...

linq nested xml
Hi, i'm using linq to load an xml structure into my classes. the xml consists of the same node nested for multiple levels e.g. <node id="node_id01" name="node 01"> <node id="node_id0101" name="node 01 01"> <node id="node_id010101" name="node 01 01 01"> <node id="node_id01010101" name="node 01 01 01 01"> <node id="node_id0101010101" name="node 01 01 01 01 01"> </node> </node> ...

.NET WebService method doesn't understand xsd list
I've posted this before but no one seems to respond. I need to know if this is a bug I am implementing a webservice against a preexisting schema/wsdl The schema specifies an element called Type that is a xml schema list of qname (i.e. it wants the message to have a space deimited list of qnames.) However wsdl.exe interprets this incorrectly as 'XmlQualifiedName Types' rather than 'XmlQualifiedName [] Types'. Simply changing the type in the C# class to an array results in incorrect serialization/exceptions. This is a fairly common piece of schema so I'm surprised ...

Nested for-each with external xml file (document('other.xml')) Issue
I am having an issue with the xsl document command. "document" being the way to refer to a different xml file as seen here: http://www.w3schools.com/Xsl/func_document.asp I have some absolute xpaths in my xml, and I loop over them. I've created a simple sample below. Basically, I can loop over (for-each) using an absolute path on the primary xml file. I can loop over the secondary xml file (another for-each statement). However, if I nest a for-each (referring to the primary xml data) inside a for-each statement (looping over data in the secondary xml), the for-ea...

XML schema class?
Hi; I know an XML schema is XML and so can be read using the XML classes. However, I was wondering if there is a class that understands a schema and can read it and returns the schema as nodes/properties in that class? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "David Thielen" <thielen@nospam.nospam> wrote in message news:2EA1508A-4123-44D3-B482-D768085CAF91@microsoft.com... > Hi; > > I know an XML schema is XML and so can be read using the XML classes. > > However, I ...

XML performance in .net?
Hi there Anyone know how fast for XML performance when I use dataset to save and read data from XML file? my client need those answers. Thanks in advance Sandra sandra wrote: > Anyone know how fast for XML performance when I use dataset to save and read > data from XML file? my client need those answers. Basically DataSet is not the fastest XML API, actually that's not XML API altogether. -- Oleg Tkachenko [XML MVP, XmlInsider] http://blog.tkachenko.com ...

How to invoke the xml editor?
I installed vs2005 on a new xp pro machine, and installed everything except C++. When I click on a file with a ".xml" extension it is opened with IE. When I click file/Edit with XML Editor, it opens it with Notepad. If I click File/Open With and select XML Editor, it opens it with IE. So, where is the xml editor? Can it be invoked from withing VS? Where? Bill * billsahiker@yahoo.com wrote in microsoft.public.dotnet.xml: >I installed vs2005 on a new xp pro machine, and installed everything >except C++. When I click on a file with a ".xml" extension it is >opened ...

"There were errors dropping ... on the designer.The XML Schema could not be interpreted from ths object."
I'm getting this error when trying to drag a table from the Server Explorer to the XSD designer. I only get the problem at home--not at work. Any ideas on how to fix this? Thanks, Chris ...

XSLT for an xml with namespace
HI can anyone help me out with this, im a newbie to xml n stuff. i really have tough time working on this . Xml file: <p:win32_Service xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://schemas.microsoft.com/wsman/2005/06/wmi/root/cimv2/win32_Service"> <p:AcceptPause>true</p:AcceptPause> <p:AcceptStop>true</p:AcceptStop> <p:Caption>Windows Management Instrumentation</p:Caption> <p:StartMode>Auto</p:StartMode> <p:StartName>LocalSystem</p:StartName> <p:State>Running</p:State> &...

XSLT and XML Schema
Hi Friends, We have a peculiar situation here, where in we have to translate a set of xml documents using xslt and we only have schemas available. How do we use XSLT here? Please advice. Ash "Ash Hart" <anonymous@discussions.microsoft.com> wrote in message news:2483EDA5-28A8-4E47-8368-8AA2B083FC78@microsoft.com... > Hi Friends, > > We have a peculiar situation here, where in we have to translate a set of xml documents using xslt and we only have schemas available. How do we use XSLT here? Please advice. To start you need a lot more: 1. Descriptiom of the desired...

Retrieve embedded XML parts from .vbs file
Hi, In our project we have a large library of VB script (.vbs) files. Each file has 1 function. I want to document these functions, so a VB.NET application can retrieve the documentation and display it. I thought that the best way to do this is in XML. Since the files in the library have to remain VB script, the XML parts have to be preceded by VB script comment characters. Something in the line of this (vbscript example): ' <Header> ' <Author>Me</Author> ' <IntialVersion>2006-02-20</IntialVersion> ' <ShortDescription>This is function...

Putting Deserialized XML back into a dataset
I have deserialized XML back into an object, so now... How do I get the object instance back into a dataset? The same XML file(before deserializing) can be put into the dataset when read as a file. Dim objPipeline As iClas_Pipelines = New iClas_Pipelines objPipeline = objPipeline.UnPack(Server.MapPath("XML/iclass_pipelines.xml")) Dim objDataset As New DataSet ----------- error--------------objDataset.ReadXml(objPipeline.Pipeline)---------error--- ---------- Where do I go from here? ...

is there in MS Office any tool to convert Visual Basic to XML?
What exactly are you looking for? Given that VB is a programming language, and XML is a means of passing information back and forth, there's not really a lot of overlap... -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gijsbert" <Gijsbert@discussions.microsoft.com> wrote in message news:705CEAA5-031F-40E7-BE9F-6EC1B0C06826@microsoft.com... > ...

Excel to XML #2
'Is there a converter for Microsoft Excel 2000 files that will save the files as .xml'. File, Save As the file extension is still .htm or .html -- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "MS" <msamant@drvc.org> wrote in message news:6d9a01c475a9$0dbed6f0$a501280a@phx.gbl... > 'Is there a converter for Microsoft Excel 2000 files that > will save the files as .xml'. ...

XML Serialization with nullable values
Hello, I have been reading a lot of pages and I cannot seem to find a easy solution for my problem... I have to deserialize (and serialize) a file which looks like this: ************** <record> <field1>data1</field1> <field2 nil="true"></field2> </record> ************** That is it... no XML header, no namespace, no comments, etc... I created a class like this: ************** public class record() { public string field1 {get; set; } [XmlElement(IsNullable=true)] public int? field2 {get; set; } } *************...

CREATE TABLE using Xml Schema
I want to dynamically create tables in a SQL Server 2000 database that are modelled after XML schemas. I will not know what the schemas might look like until the documents arrive. For example, I'd like to convert this schema: <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:element name="OrgLevel"> <xs:complexType> <xs:sequence> <xs:element name="code" type="integer" /> <xs:element name="desc" type=&qu...

Large XML data loading?
I have a large (50 million records) XML table data in one of the database that I need to load into another database table. I already have several indexes on the table and due to space issues I can not add any more indexes on the table that includes on the XML field (data.value) I am querying. This query is very slow and can take as long as six days to run. What are my options to improve the performance? Is partition is the way to go? Divide data into smaller portions for loading using row_number function?..... On Thu, 15 Jul 2010 15:57:36 -0700 (PDT), Bero <robertatnova@gmail....

[ANN]VTD-XML 2.1
This is a multi-part message in MIME format. ------=_NextPart_000_00D3_01C7B199.5250FB20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable VTD-XML 2.1 is released. This version contains a number of features and = bug fixes.=20 * The BookMark class is introduced into all available plaforms of = VTD-XML.=20 * C# and Java port of VTD-XML fix the bug of unicode chars in XPath = expression.=20 * C version of VTD-XML has numerous code clean-ups. ------=_NextPart_000_00D3_01C7B199.5250FB20 Content-Type: text/html; charset="iso-8859-1" ...

Word document creation in XML
Hi All, I'm pretty new to .Net, not to mention XML, so I truly appreciate any advice! I have user data that I want to selectively insert into a MS Word document in XML. Given the various content, I want to create a new instance of an XML document and write the data to the XML doc using the Word ML schema. The key item is that I want to be able to add content line-by-line or section-by-section, to the word document using the XML schema. The reason behind this is that the content will change dramatically. The question comes down to this -- are there already-defined components that...

Identifying all Namespace / Prefixes when reading an XML
How do I identify all of the namespace / prefix pairs associated with an XML document I am reading? Thanks for any help. Paul PaulF wrote: > How do I identify all of the namespace / prefix pairs associated with an XML > document I am reading? XPath has a namespace axis you could have your code walk. It depends on how you read your XML document, with Xml(Text)Reader you do not have XPath support. With XPathDocument or XmlDocument you do. XPath expression is //namespace::* or (with duplicates removed) //namespace::*[not(. = ../../namespace::*] Note that the prefix xml is a...

About xml namespace.
Hi, I am new to this xml specifically saying Atom syndication, and getting confusion with the URL used in the namespace. What it signifies? I tried copying the URL into address bar, its giving page not found. I am using the xml content like below for posting a photo to picasa web album. <entry xmlns="http://www.w3.org/2005/Atom"> <title>example.jpg</title> <category scheme="http://schemas.google.com/g/ 2005#kind" term="http://schemas.google.com/photos/2007#photo" /> </entry> i tried ch...