我有以下字符串如何从一个XML字符串特定值在C#
<SessionInfo>
<SessionID>MSCB2B-UKT3517_f2823910df-5eff81-528aff-11e6f-0d2ed2408332</SessionID>
<Profile>A</Profile>
<Language>ENG</Language>
<Version>1</Version>
</SessionInfo>
现在我想要得到的的值的SessionID。我试着用下面..
var rootElement = XElement.Parse(output);//output means above string and this step has values
但在这里,,
var one = rootElement.Elements("SessionInfo");
它没有我不work.what能做到这一点。
而如果像below.can我们使用相同的XML字符串得到会话ID
<DtsAgencyLoginResponse xmlns="DTS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="DTS file:///R:/xsd/DtsAgencyLoginMessage_01.xsd">
<SessionInfo>
<SessionID>MSCB2B-UKT351ff7_f282391ff0-5e81-524548a-11eff6-0d321121e16a</SessionID>
<Profile>A</Profile>
<Language>ENG</Language>
<Version>1</Version>
</SessionInfo>
<AdvisoryInfo />
</DtsAgencyLoginResponse>
不错,它工作。我投了票,我会接受答案。 – bill
可以请你看看第二部分 – bill
@bill这是一个完全不同的问题 – HimBromBeere