このxmlのエントリごとに、「タイトル」と最初のサムネイル画像を取得する必要があります。それはmedia:groupの最初の画像です
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/'>
<entry>
<title>Progression! 9 more pounds to goo!</title>
<media:group>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/default.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/mqdefault.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/hqdefault.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/1.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/2.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/7MTjYXt3rLQ/3.jpg'/>
</media:group>
</entry>
<entry>
<title>Plank Variations Workout with Max Wettstein</title>
<media:group>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/default.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/mqdefault.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/hqdefault.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/1.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/2.jpg'/>
<media:thumbnail url='http://i.ytimg.com/vi/O1Nd8lZFGpc/3.jpg'/>
</media:group>
</entry>
</feed>
これは私のコードです
Dim xmlDoc As MSXML2.DOMDocument30
Dim xmlEntryNode As MSXML2.IXMLDOMNode
Dim xmlEntryNodes As IXMLDOMNodeList
Dim xmlC1Nodes As IXMLDOMNodeList
Dim ns As String
Set xmlDoc = New DOMDocument30
ns = txtNS.Text
xmlDoc.setProperty "SelectionLanguage", "XPath"
xmlDoc.setProperty "SelectionNamespaces", ns
If xmlDoc.loadXML(txtXml.Text) = False Then
appendText "xml document load failed"
Exit Sub
End If
Set xmlEntryNodes = xmlDoc.documentElement.selectNodes(/x:feed/x:entry)
Dim i As Integer
For i = 0 To xmlEntryNodes.length - 1
Set xmlEntryNode = xmlEntryNodes(i)
appendText xmlEntryNode.Text
Set xmlC1Nodes = xmlDoc.selectNodes(//media:group/media:thumbnail[1]/@url)
If xmlC1Nodes.length > 0 Then
Dim j As Integer
For j = 0 To xmlC1Nodes.length - 1
appendText xmlC1Nodes(j).Text
Next
End If
Next
Exit Sub
これが私の出力です
Progression! 9 more pounds to goo!
http://i.ytimg.com/vi/7MTjYXt3rLQ/default.jpg
http://i.ytimg.com/vi/O1Nd8lZFGpc/default.jpg Plank Variations
Workout with Max Wettstein
http://i.ytimg.com/vi/7MTjYXt3rLQ/default.jpg
http://i.ytimg.com/vi/O1Nd8lZFGpc/default.jpg
誰かplsは、エントリごとに1つの画像のみを返すように調整するのを手伝ってくれますか?