我有以下字符串
<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
在这里,但需要涉及到IT技术相关内容。
var one = rootElement.Elements("SessionInfo");
它没起作用。我该怎么办。
如果以下xml字符串,我们可以使用相同的方法来获取sessionID吗?
<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>
xmlns="DTS"
。尝试搜索如何使用LINQ-to-XML选择命名空间中的元素... - har07