我需要更新我的手机号码和地址。我的程序从数据库中读取XML字符串。我能够阅读手机号码。我怎么能在同一个for循环中读取地址。我还需要在读取后修改这些值。
XML字符串在
下面$programs = ScheduledProgram::where('registration_start_date', '<=', $today)
->where('end_date', '>=', $today)
->whereHas('attendees', function($q) use($user)
{
$q->whereHas('user', function($q) use($user){
$q->where('id', $user->id);
});
})
->wherePivot('registered', 1)
->get();
我的代码写在下面
<?xml version="1.0" encoding="utf-16"?>
<Test>
<authentication>
<company>Harissons</company>
<username>API@hariisons.co.uk</username>
<password>Pa55word67</password>
</authentication>
<sessions>
<session RID="0cee7f47-59b4-4fb2-a8eb-bafba9dec8ee">
<data>
<Checksrequired>
<BankStandard>Yes</BankStandard>
<BankEnhanced>Yes</BankEnhanced>
<CardLive>No</CardLive>
<CardEnhanced>No</CardEnhanced>
<IDEnhanced>Yes</IDEnhanced>
<DeliveryFraud>No</DeliveryFraud>
<EmailValidate>No</EmailValidate>
<CreditScore>No</CreditScore>
<Zodiac>No</Zodiac>
<IPAddress>No</IPAddress>
</Checksrequired>
<Personalinformation>
<IndividualDetails>
<Title>Mr.</Title>
<Firstname>test</Firstname>
<Surname>test</Surname>
<Dateofbirth>1996-02-01T00:00:00</Dateofbirth>
<Emailaddress>xyz@gmail.com</Emailaddress>
</IndividualDetails>
<AddressDetails>
<Buildingname></Buildingname>
<Postcode>se93qS</Postcode>
<Previouspostcode />
</AddressDetails>
</Personalinformation>
<mobilenumber>9488488484</mobilenumber>
<address>testaddress</address>
</data>
</session>
</sessions>
<application>LT-API-BEML</application>
</Test>
答案 0 :(得分:1)
试试这个
var mobileNumbers = testxml.Descendants("data").Select(x => new {
mobilenumber = x.Element("mobilenumber").Value,
address = x.Element("address").Value,
}).ToList();