The xml file is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Record_info RecordIndex = "1" Upload2ShareCenterTimes = "1" Upload2ResShareCenter = "1" Upload2ShareCenterStatus = "2">
<LessonGUID> 22DE52E8-3AB6-42DE-9014-2E44B33A0E11 </LessonGUID>
<RecTime StartTime = "14:49:36" EndTime = "14:49:51"/>
<CourseName> 22 </CourseName>
<LessonName> 11 </LessonName>
<SpeakerName> 22 </SpeakerName>
<Introduction/>
<ImageIndex>
<Index Name = "24008984.jpg" Time =" 00:00:00 "/>
</ImageIndex>
<ChannelInfo Count = "4">
<Channel Name = "instructor desktop" Type = "0" ID = "0" Resolution = "640 480" Quality = "60" BandWidth = "768" FrameRate = "15" Keyframe = "100" EncMode = "VBR" Deinterlace = "0" Denoise = "0"/>
<Channel Name = "instructor Channel" Type = "1" ID = "1" Resolution = "640 480" Quality = "60" BandWidth = "768" FrameRate = "25" Keyframe = "100" EncMode = "CBR" Deinterlace = "1" Denoise = "1"/>
<Channel Name = "Student Channel" Type = "3" ID = "3" Resolution = "640 480" Quality = "60" BandWidth = "768" FrameRate = "25" Keyframe = "100" EncMode = "VBR" Deinterlace = "1" Denoise = "1"/>
<Channel Name = "panoramic video" Type = "2" ID = "2" Resolution = "720 576" Quality = "60" BandWidth = "768" FrameRate = "25" Keyframe = "100" EncMode = "VBR" Deinterlace = "1" Denoise = "1"/>
</ChannelInfo>
<VidInfo IsRecSM = "1" IsRecMM = "1" SMFormat = "1" MMFormat = "2" TotalTime = "00:00:12">
<Vid_SM SplitCount = "4">
<RecFile Name = "20151115144936.iac" Format =" 1 "Channel ="-1 "/>
</Vid_SM>
<Vid_MM VidSize = "720 576">
<RecFile Name = "20151115144936_m.wmv" Format = "2"/>
</Vid_MM>
</VidInfo>
</Record_info>
Read <RecFile Name = "20151115144936_m.wmv" Format = "2"/> the Name of the node, and Format = 2
The implementation code is as follows:
Public static string GetVideoFile (string url)
{
String videoFilename = null;
// Var ss = from e in XDocument. Load (url). Elements ("record_info"). Elements ("Vid_MM"). Elements ("RecFile ")
Var query = from c in XDocument. Load (url). Elements ("record_info"). Elements ("VidInfo"). Elements ("Vid_MM"). Elements ("RecFile ")
Where (string) c. Attribute ("Format"). Value = "2"
Select c;
Foreach (var book in query)
{
VideoFilename = book. Attribute ("Name"). Value;
}
Return videoFilename = null? Null: videoFilename;
}