如何反序列化具有多个命名空间的 xml?
我正在从 youtube 中提取 xml:https ://gdata.youtube.com/feeds/api/users/OnlyChillstep?v=2
我可以得到 <title>、<summary>,但不能得到 <yt:location>
这是课程,我也尝试放置 ElementName:="yt:location" 没有成功
<Xml.Serialization.XmlRoot(elementname:="entry", namespace:="http://www.w3.org/2005/Atom")> _
Public Class YoutubeFeed
<XmlElement(ElementName:="title")> _
Public title As String
<XmlElement(ElementName:="location")> _
Public location As String
End Class
Dim requestUri2 As String = "https://gdata.youtube.com/feeds/api/users/OnlyChillstep?v=2"
Dim request2 As HttpWebRequest = DirectCast(WebRequest.Create(requestUri2), HttpWebRequest)
Dim resultSet2 As YoutubeFeed
Using response2 As WebResponse = request2.GetResponse()
Using responseStream As Stream = response2.GetResponseStream()
Dim serializer As New XmlSerializer(GetType(YoutubeFeed))
resultSet2 = DirectCast(serializer.Deserialize(responseStream), YoutubeFeed)
End Using
End Using
Console.WriteLine(resultSet2.title)
Console.WriteLine(resultSet2.location)