我一直在使用 Windows Phone 7 应用程序,在从 Web 服务获取数据时遇到了问题。我从服务器以这样一种模式得到响应,以至于我无法弄清楚如何获取它。请帮我。下面是来自服务器的响应。
此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。
<response xmlns="uri:abc.com" status="Ok" op="DelegateList" msg="Get Delegate List Successful">
<list count="19">
<delegateinfo photoid="" id="12936">
<prop value="A" name="fname" label="First Name"/>
<prop value="A" name="lname" label="Last Name"/>
<prop value="Karachi, PK" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12938">
<prop value="aaa" name="fname" label="First Name"/>
<prop value="aaaa" name="lname" label="Last Name"/>
<prop value="aa" name="ptitle" label="Professional Title"/>
<prop value="aaaa" name="company" label="Company"/>
<prop value="aa,aa" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12949">
<prop value="ad" name="fname" label="First Name"/>
<prop value="ad" name="lname" label="Last Name"/>
<prop value="a,b" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12956">
<prop value="Asdsad" name="fname" label="First Name"/>
<prop value="Asdasd" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12955">
<prop value="asd" name="fname" label="First Name"/>
<prop value="Asdd" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12963">
<prop value="A" name="fname" label="First Name"/>
<prop value="B" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12964">
<prop value="a" name="fname" label="First Name"/>
<prop value="B" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12929">
<prop value="G" name="fname" label="First Name"/>
<prop value="F" name="lname" label="Last Name"/>
<prop value="Karachi, PK" name="ccountry" label="Country / City"/>
<prop value="Arts & Music" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="1292620120724105446.jpg" id="12926">
<prop value="faraz" name="fname" label="First Name"/>
<prop value="haider" name="lname" label="Last Name"/>
<prop value="Team Leader Iphone at Cubix Labs Inc" name="ptitle" label="Professional Title"/>
<prop value="Cubix Labs Inc." name="company" label="Company"/>
<prop value="Karachi, Pakistan" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="1292120120723075111.jpg" id="12921">
<prop value="cubix" name="fname" label="First Name"/>
<prop value="labs" name="lname" label="Last Name"/>
<prop value="iphone developer at Social Cubix" name="ptitle" label="Professional Title"/>
<prop value="Social Cubix" name="company" label="Company"/>
<prop value="test,test" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12939">
<prop value="New" name="fname" label="First Name"/>
<prop value="One" name="lname" label="Last Name"/>
<prop value="Karachi, PK" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12961">
<prop value="E" name="fname" label="First Name"/>
<prop value="Qwe" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12957">
<prop value="s" name="fname" label="First Name"/>
<prop value="S" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12965">
<prop value="dassd" name="fname" label="First Name"/>
<prop value="Sadds" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12960">
<prop value="Asfdcasscf" name="fname" label="First Name"/>
<prop value="Sff" name="lname" label="Last Name"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Dehli, India" name="ccountry" label="Country / City"/>
<prop value="Architecture" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12922">
<prop value="Michael" name="fname" label="First Name"/>
<prop value="Tabour" name="lname" label="Last Name"/>
<prop value="Software Engineer" name="ptitle" label="Professional Title"/>
<prop value="Cubix Labs" name="company" label="Company"/>
<prop value="Maryland, United States" name="ccountry" label="Country / City"/>
<prop value="IT Services, Internet & Telecommunications" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="1292020120723075408.jpg" id="12920">
<prop value="test" name="fname" label="First Name"/>
<prop value="test" name="lname" label="Last Name"/>
<prop value="test" name="ptitle" label="Professional Title"/>
<prop value="test" name="company" label="Company"/>
<prop value="test, test" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
<delegateinfo photoid="" id="12933">
<prop value="Test" name="fname" label="First Name"/>
<prop value="Test1" name="lname" label="Last Name"/>
<prop value="Coderu" name="ptitle" label="Professional Title"/>
<prop value="Xyz pvt ltd" name="company" label="Company"/>
<prop value="Karachi, PK" name="ccountry" label="Country / City"/>
<prop value="Airlines & Aviation" name="industry" label="Industry"/>
</delegateinfo>
</list>
</response>
我用来填充它的代码并没有给我任何想要的结果:
XDocument ListArray= XDocument.Parse(e.Result);
var quotes = from quote in ListArray.Descendants("response").Descendants("list").Descendants("delegateinfo").Descendants("prop")
select new delegateinfo
{
lastName = quote.Attribute("value").Value
};
foreach (delegateinfo stockQuote in quotes)
{
MessageBox.Show (stockQuote.lastName);
}