我有这个xml:
<?xml version="1.0" encoding="UTF-8"?>
<CueList xmlns="urn:CueListSchema.xml" xmlns:s="urn:schemas-rcsworks-com:SongSchema" xmlns:n="urn:schemas-rcsworks-com:NoteSchema" xmlns:l="urn:schemas-rcsworks-com:LinkSchema" xmlns:t="urn:schemas-rcsworks-com:TrafficSchema" xmlns:p="urn:schemas-rcsworks-com:ProductSchema" xmlns:m="urn:schemas-rcsworks-com:MediaSchema" xmlns:w="urn:schemas-rcsworks-com:WebPageSchema" xmlns:ns="urn:CueListSchema.xml" time="2011-12-02T13:34:39">
<Event eventID="14" eventType="song" status="happening" scheduledTime="13:34:38" scheduledDuration="332.82">
<s:Song title="Long Time Coming (Holding On)" internalID="007700028007AD480000">
<s:Artist name="The Winans" sequenceNumber="1" internalID="0067000180002B020000" sortName="Winans, The" />
<m:Media ID="{7C734B6C-7AF7-4998-8366-F1F11F5D56D7}" runTime="332.82" fileName="{7C734B6C-7AF7-4998-8366-F1F11F5D56D7}.wav" />
</s:Song>
</Event>
<Event eventID="15" eventType="link" status="committed" startTime="13:40:10" scheduledDuration="3.49">
<l:Link title="PG MFL DRY FEMALE" internalID="007B00028002DAEA0000">
<m:Media ID="{036BB0ED-3130-4AD0-8BAF-E5D0FBA7DC3B}" runTime="3.49" fileName="{036BB0ED-3130-4AD0-8BAF-E5D0FBA7DC3B}.wav" />
</l:Link>
</Event>
<Event eventID="16" eventType="song" status="committed" startTime="13:40:10" scheduledDuration="303.55">
<s:Song title="Not Making Sense, Making Faith" internalID="007700028009377F0000">
<s:Artist name="Donald Lawrence" sequenceNumber="1" internalID="006700018000308A0000" sortName="Lawrence, Donald" />
<m:Media ID="{B6FD04EA-9B42-4E6A-AC80-A26BF65E6F11}" runTime="303.55" fileName="{B6FD04EA-9B42-4E6A-AC80-A26BF65E6F11}.wav" />
</s:Song>
</Event>
</CueList>
我能够为歌曲等设置命名空间。但是当我尝试选择事件时它不起作用,我尝试为CueList设置命名空间,当我调试它时说命名空间为空?
答案 0 :(得分:0)
当您没有显示您正在使用的代码时,很难知道错误是什么,但它应该很简单:
XNamespace ns = "urn:CueListSchema.xml";
var events = doc.Descendants(ns + "Event");
如果这不起作用,请给我们一个简短的但是完整的XML示例(格式化,请,而不仅仅是从浏览器中复制)并编码您的代码&#39;重新使用。