using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
string myXML = @"<LowestOfferListings>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Acceptable</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
<NumberOfOfferListingsConsidered>3</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>8900</SellerFeedbackCount>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<MultipleOffersAtLowestPrice>True</MultipleOffersAtLowestPrice>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Good</ItemSubcondition>
<FulfillmentChannel>Amazon</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<SellerPositiveFeedbackRating>90-94%</SellerPositiveFeedbackRating>
<NumberOfOfferListingsConsidered>1</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>1569694</SellerFeedbackCount>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
<ItemCondition>Used</ItemCondition>
<ItemSubcondition>Good</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
<NumberOfOfferListingsConsidered>3</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>7732</SellerFeedbackCount>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<CurrencyCode>USD</CurrencyCode>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
XDocument xdoc = new XDocument();
xdoc = XDocument.Parse(myXML);
var result = xdoc.Descendants().Elements()
.Where(d => d.Name.LocalName == "LowestOfferListing");
foreach (XElement item in result) {
var LandedPrice_Node = item.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "LandedPrice");
string price = LandedPrice_Node.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "Amount").FirstOrDefault().Value;
string ItemCondition = item.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "ItemCondition").FirstOrDefault().Value;
string FulfillmentChannel = item.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "FulfillmentChannel").FirstOrDefault().Value;
string SellerPositiveFeedbackRating = item.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "SellerPositiveFeedbackRating").FirstOrDefault().Value;
string SellerFeedbackCount = item.DescendantsAndSelf().Elements()
.Where(d => d.Name.LocalName == "SellerFeedbackCount").FirstOrDefault().Value;
price = "<td>$" + price + "</td>";
ItemCondition = "<td>(" + ItemCondition + ")</td>";
FulfillmentChannel = "<td data-toggle='tooltip' title='Seller Feedback Rating and count: " + SellerPositiveFeedbackRating + " (" + SellerFeedbackCount + ")'>" + FulfillmentChannel + "</td>";
returnHTML = returnHTML + "<tr>" +
ViewBag.AllOffers = "<table>" + returnHTML + "<table>";
ViewBag.BuyBox = "$39.99";
return View(new SampleViewModel());
public JsonResult GetAnswer(string question)
int index = _rnd.Next(_db.Count);
private static Random _rnd = new Random();
private static List<string> _db = new List<string> { "Yes", "No", "Definitely, yes", "I don't know", "Looks like, yes"} ;