Unable to get value of element... code and XML attached

Here is the XML I am working with...
 
<ItemLookupResponse>
<Items>
<Request>
<IsValid>True</IsValid>
<ItemLookupRequest>
<IdType>UPC</IdType>
<MerchantId>All</MerchantId>
<ItemId>096741144127</ItemId>
<ResponseGroup>Medium</ResponseGroup>
<SearchIndex>Music</SearchIndex>
</ItemLookupRequest>
</Request>
<Item>
<ASIN>B000WGWWB2</ASIN>
<DetailPageURL>

Open in new window


This is my code that I am trying to access the value of the ASIN element.
 
br.Read();
                br.MoveToFirstAttribute();

                br.MoveToAttribute("Items");
                br.MoveToAttribute("Item");
                br.MoveToAttribute("ASIN");
                br.Read();
                mtbASIN.Text = br.Value;  //  move ASIN

Open in new window


It's not working... what do I need to do to get the value of the ASIN element?
rmmarshAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Heheh, my mistake. I guess I should have read the docs before trying to quote them  = )

Try using ReadToFollowing instead:

br.Read();
br.MoveToFirstAttribute();

br.ReadToFollowing("Items");
br.ReadToFollowing("Item");
br.ReadToFollowing("ASIN");
br.Read();
mtbASIN.Text = br.Value;  //  move ASIN

Open in new window

0
 
käµfm³d 👽Commented:
Those are not attributes--they are elements. You are using the wrong function to navigate your document. Try using MoveToElement instead.

br.Read();
br.MoveToFirstAttribute();

br.MoveToElement("Items");
br.MoveToElement("Item");
br.MoveToElement("ASIN");
br.Read();
mtbASIN.Text = br.Value;  //  move ASIN

Open in new window

0
 
rmmarshAuthor Commented:
Hi Kenneth... there is NO method MoveToElement that takes a parameter.  So I guess the next question is:  how do I get to the specific element "ASIN"?
0
 
rmmarshAuthor Commented:
As usual, you came through!  You're the man!

Spokane-Dude
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.