我有以下字符串如何從一個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