weaponx Posted November 9, 2008 Share Posted November 9, 2008 Hey everyone. I'm sorry, but I've been fidgeting around with this script since last night and have made no progress understanding the functions.The areas that are in brackets will be filled in with the according information, so don't worry about them. I'm making a script that converts .atom (xml format) files to Excel Spreadsheats for a project a friend of mine is doing. For whatever reason, when I do _XMLGetChildNodes("/feed"), it completely skips Link and Generator. What I need to do is store the 'ID', 'JOINED DATE', 'ACTIVITY', and 'ACTIVITY DATE' content contained in each ENTRY (of which there are many hundred) into an array. I have attempted this, but to be honest, I'm having a lot of trouble understanding the functions in this UDF and when to use them based on the rather frustrating descriptions provided, as I am not an expert at xml structure.Thank you to everyone who helps out and thank you for an awesome UDFYour XML doesn't validate, you need a closing tag for 'feed' at the end of the document...like this </feed> Link to comment Share on other sites More sharing options...
t8inevergreen Posted November 9, 2008 Share Posted November 9, 2008 Your XML doesn't validate, you need a closing tag for 'feed' at the end of the document...like this </feed>My bad, I took the first couple of ENTRY's from the feed for the example and forgot to close the first tag So, I was under the impression that <div class='joinedDate'>Mon Dec 31 11:16:17 EST 2007</div>was still a node even though it has attributes. But this UDF says otherwise because tags that look like that ^ will not show up when I do _XMLGetChildNodes. What is a way that I can work around this? Am I using the wrong function? Link to comment Share on other sites More sharing options...
weaponx Posted November 9, 2008 Share Posted November 9, 2008 My bad, I took the first couple of ENTRY's from the feed for the example and forgot to close the first tag So, I was under the impression that <div class='joinedDate'>Mon Dec 31 11:16:17 EST 2007</div> was still a node even though it has attributes. But this UDF says otherwise because tags that look like that ^ will not show up when I do _XMLGetChildNodes. What is a way that I can work around this? Am I using the wrong function? For some reason your xml won't parse with this line in the 'feed' namespace: xmlns="http://www.w3.org/2005/Atom" If you cut that out it works just fine. expandcollapse popup#include "..\_XMLDomWrapper.au3" $oXMLFile = _XMLFileOpen("atom.xml") Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch $title = _GetFirstValue("//title") ConsoleWrite("Title: " & $title & @CRLF) $href = _XMLGetAttrib('//link', 'href') ConsoleWrite('Href: ' & $href & @CRLF) $id = _GetFirstValue("//id") ConsoleWrite('Id: ' & $id & @CRLF) ;Retrieve count of entry nodes $result = _XMLSelectNodes('//entry') If IsArray($result) Then For $X = 1 to $result[0] ConsoleWrite("Entry "&$X&": " & _GetFirstValue('//entry[' & $X & ']/content/div[@class="id"]') & @CRLF) Next Else ConsoleWrite("NOT AN ARRAY" & @CRLF) EndIf ;Get the first real value returned from the _XMLGetValue() return array. REQUIRED Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFunc Link to comment Share on other sites More sharing options...
weaponx Posted November 9, 2008 Share Posted November 9, 2008 Here is another way to work with the Atom XML without modifying the file itself. expandcollapse popup#include "..\_XMLDomWrapper.au3" $xmlns = 'xmlns:at="http://www.w3.org/2005/Atom" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' $oXMLFile = _XMLFileOpen("atom.xml", $xmlns) Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch ;MsgBox(0,"",$objDoc.documentElement.namespaceURI) $title = _GetFirstValue("//at:title") ConsoleWrite("Title: " & $title & @CRLF) $href = _XMLGetAttrib('//at:link', 'href') ConsoleWrite('Href: ' & $href & @CRLF) $id = _GetFirstValue("//at:id") ConsoleWrite('Id: ' & $id & @CRLF) ;Retrieve count of entry nodes $result = _XMLSelectNodes('//at:entry') If IsArray($result) Then For $X = 1 to $result[0] ConsoleWrite("Entry "&$X&": " & _GetFirstValue('//at:entry[' & $X & ']/at:content/at:div[@class="id"]') & @CRLF) Next Else ConsoleWrite("NOT AN ARRAY" & @CRLF) EndIf ;Get the first real value returned from the _XMLGetValue() return array. REQUIRED Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFunc Link to comment Share on other sites More sharing options...
subfighter Posted November 11, 2008 Share Posted November 11, 2008 (edited) okay weaponx i used your examples you posted for the other guy as it helped me see where the errors were.. Basically I am pulling the .xml file from YOUTUBE but there was a parsing error.. i dont know why... So then i saved the file first then opened it and that solved the parsing issue..Then i had to add the $xmlns variable you posted above then it was able to read the .xml file. I do not know what the $xmlns variable does but why does it allow it to read the file properly?so i used your examples and where able to pull the info from the CHILD NODES but there are the other nodes in the media:group and could not find any example of extracting the data from those using the UDF?i need to extract the data for all the nodes between the media:group from the videoinfo.xml file below<?xml version='1.0' encoding='UTF-8'?> <entry xmlns='http://www.w3.org/2005/Atom' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'> <id>http://gdata.youtube.com/feeds/api/videos/HfJ91N5dzIE</id> <published>2008-11-04T16:19:59.000Z</published> <updated>2008-11-11T14:31:45.000Z</updated> <media:group> <media:title type='plain'>2 Points For Kissing (HBO)</media:title> <media:description type='plain'>Trenton Titsworth kisses Jesse Vargas and Vargas doesn't take very kindly to it. Titsworth gets deducted 2 points for kissing. For more on HBO Boxing, log onto HBO.com.</media:description> <media:keywords>Boxing, championship, HBO, Jesse, jim, lampley, Titsworth, Trenton, Vargas, world</media:keywords> <yt:duration seconds='151'/> <media:thumbnail url='http://i.ytimg.com/vi/HfJ91N5dzIE/2.jpg' height='97' width='130' time='00:01:15.500'/> <media:thumbnail url='http://i.ytimg.com/vi/HfJ91N5dzIE/1.jpg' height='97' width='130' time='00:00:37.750'/> <media:thumbnail url='http://i.ytimg.com/vi/HfJ91N5dzIE/3.jpg' height='97' width='130' time='00:01:53.250'/> <media:thumbnail url='http://i.ytimg.com/vi/HfJ91N5dzIE/0.jpg' height='240' width='320' time='00:01:15.500'/> <media:player url='http://www.youtube.com/watch?v=HfJ91N5dzIE'/> </media:group> </entry>oÝ÷ Ú«z+»{®*mj¢i׶£ 塧ij»hºÖ®¶sb6æ6ÇVFRfÇCµõÔÄFöÕw&W"æS2fwC°¢6æ6ÇVFRfÇC´æWBæS2fwC° £²6WBfFVòFFfVVBU$À£²b33c¶fVVEU$ÂÒôæWDvWE6÷W&6RgV÷C¶GG¢òövFFç÷WGV&Ræ6öÒöfVVG2ö÷fFV÷2ôd£ãVG¤RgV÷C² £²F÷væÆöBÖÂfÆRFò£´æWDvWBgV÷C¶GG¢òövFFç÷WGV&Ræ6öÒöfVVG2ö÷fFV÷2ôd£ãVG¤RgV÷C²ÂgV÷C·fFVöæfòçÖÂgV÷C²Â £µÔÂfÆRFò÷Vࣲb33cµÔÆfÆRÒb33c¶fVVEU$À ¢b33c·ÖÆç2Òb33·ÖÆç3¦CÒgV÷C¶GG¢ò÷wwrçs2æ÷&ró#RôFöÒgV÷C²ÖÆç3§FóÒgV÷C¶GG¢ò÷W&Âæ÷&r÷'72óãöÖöGVÆW2÷Föæö×ògV÷C²ÖÆç3¦F3ÒgV÷C¶GG¢ò÷W&Âæ÷&röF2öVÆVÖVçG2óãògV÷C²ÖÆç3§7ÒgV÷C¶GG¢ò÷W&Âæ÷&r÷'72óãöÖöGVÆW2÷7æF6FöâògV÷C²ÖÆç3§&FcÒgV÷C¶GG¢ò÷wwrçs2æ÷&róó"ó#"×&Fb×7çFÖç22gV÷C²b33°¢b33c¶õÔÄfÆRÒõÔÄfÆT÷VâgV÷C·fFVöæfòçÖÂgV÷C²Âb33c·ÖÆç2¥7vF6W'&÷ ¢66R¢6öç6öÆUw&FRgV÷C´æòW'&÷"gV÷C²fײ5$Äb¢66R¢6öç6öÆUw&FRgV÷Cµ'6RW'&÷"gV÷C²fײ5$Äb¢66R ¢6öç6öÆUw&FRgV÷C´æòö&¦V7BgV÷C²fײ5$Äb¤VæE7vF6 ¢b33c¶BÒôvWDf'7EfÇVRgV÷C²òöC¦BgV÷C²¤6öç6öÆUw&FRgV÷C´C¢gV÷C²fײb33c¶Bfײ5$Äb ¢b33c·V&Æ6VBÒôvWDf'7EfÇVRgV÷C²òöC§V&Æ6VBgV÷C²¤6öç6öÆUw&FRgV÷CµV&Æ6VC¢gV÷C²fײb33c·V&Æ6VBfײ5$Äb ¢b33c·WFFVBÒôvWDf'7EfÇVRgV÷C²òöC§WFFVBgV÷C²¤6öç6öÆUw&FRgV÷CµWFFVC¢gV÷C²fײb33c·WFFVBfײ5$Äb £µ&WG&WfR6÷VçBöbVçG'æöFW0£·âb33c·&W7VÇBÒõÔÅ6VÆV7DæöFW2b33²òöC¦VçG'b33²£·âb4'&b33c·&W7VÇBFVࣷâf÷"b33cµÒFòb33c·&W7VÇE³Ð£·â6öç6öÆUw&FRgV÷C´VçG'gV÷C²fײb33cµfײgV÷C³¢gV÷C²fײôvWDf'7EfÇVRb33²òöC¦VçG'²b33²fײb33cµfײb33µÒöC¦ÖVF¦w&÷Wb33²fײ5$Äb£·âæW@£·âVÇ6P£·â6öç6öÆUw&FRgV÷C´äõBâ%$gV÷C²fײ5$Äb£·âVæD` £³´vWBFRf'7B&VÂfÇVR&WGW&æVBg&öÒFRõÔÄvWEfÇVR&WGW&â'&â$UT$T@¤gVæ2ôvWDf'7EfÇVRb33c¶æöFR¢b33c·&WE÷fÂÒõÔÄvWEfÇVRb33c¶æöFR¢b4'&b33c·&WE÷fÂFVà¢&WGW&âb33c·&WE÷fųҢVÇ6P¢&WGW&â6WDW'&÷"Ã2âVæD`¤VæDgVæ Edited November 12, 2008 by subfighter Link to comment Share on other sites More sharing options...
weaponx Posted November 11, 2008 Share Posted November 11, 2008 (edited) Declaring the namespace when you open the XML overrides the namespace definition in the root of the XML. When the root namespace is declared like this it causes problems: xmlns='http://www.w3.org/2005/Atom' So to override that you call _XMLFileOpen with a namespace declaration: xmlns:anything='http://www.w3.org/2005/Atom' This will make all nodes in your XML that don't have a namespace prefix identifiable with 'anything'. So if you have a node like this <node></node> you will now match it with 'anything:node'. Make sense? So you copy the namespace from your XML and paste it in the $xmlns variable: $xmlns = "xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'" EDIT: I'll test the code in just a bit, I have to eat lunch first. Edited November 11, 2008 by weaponx Link to comment Share on other sites More sharing options...
subfighter Posted November 11, 2008 Share Posted November 11, 2008 (edited) okay i understand know a bit more on what you explained above.. so i added the ones below that youtube sends ad just added xmlns:at and it works.. $xmlns = 'xmlns:at="http://www.w3.org/2005/Atom" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:gd="http://schemas.google.com/g/2005"'so i am just trying to understand that the above links like engines that are called and then used to parse the data out of the XML file?So i tried with logic to get some of the other values and it worked for the 3 of them $title = _GetFirstValue("//media:title") ConsoleWrite("Title: " & $title & @CRLF) $description = _GetFirstValue("//media:description") ConsoleWrite("Description: " & $description & @CRLF) $keywords = _GetFirstValue("//media:keywords") ConsoleWrite("Keywords: " & $keywords & @CRLF)okay i figured the right syntax for the yt:duration and the player with the Attributes..$player = _XMLGetAttrib("//media:player", "url") ConsoleWrite("Player: " & $player & @CRLF) $duration = _XMLGetAttrib("//yt:duration" , "seconds") ConsoleWrite("Duration: " & $duration & @CRLF)but how I get the 4 thumbnails media:thumbnailthis is all new to me so sorry if i do not know what the hell going on.. i am trying thanks for the help as i understand it somewhat now i think.. Edited November 11, 2008 by subfighter Link to comment Share on other sites More sharing options...
weaponx Posted November 11, 2008 Share Posted November 11, 2008 but how I get the 4 thumbnails media:thumbnail this is all new to me so sorry if i do not know what the hell going on.. i am trying thanks for the help as i understand it somewhat now i think.. Those are easy. _XMLGetAttrib("//media:thumbnail[1]", 'url') _XMLGetAttrib("//media:thumbnail[2]", 'url') _XMLGetAttrib("//media:thumbnail[3]", 'url') _XMLGetAttrib("//media:thumbnail[4]", 'url') Link to comment Share on other sites More sharing options...
subfighter Posted November 11, 2008 Share Posted November 11, 2008 thanks.. as i looked at your other example and was trying to figure it out with a loop but no matter what tried the loop would not work at it always showed 4 of the same CODE For $X = 1 to 4 $thumbnail = _XMLGetAttrib("//media:thumbnail[' & $X & ']", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) Next so ended doing it like you showed above in the example and it worked. CODE$thumbnail = _XMLGetAttrib("//media:thumbnail[1]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[2]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[3]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[4]", "url") thanks but now going to try to move on where there is 40 VIDEO INFO in the feed and extract.. so hopefully i can figure it out as i will have to run some loops like in your above example where counted the nodes then ran the loop.. thanks again... Link to comment Share on other sites More sharing options...
weaponx Posted November 11, 2008 Share Posted November 11, 2008 thanks but now going to try to move on where there is 40 VIDEO INFO in the feed and extract.. so hopefully i can figure it out as i will have to run some loops like in your above example where counted the nodes then ran the loop.. thanks again... expandcollapse popup#include "_XMLDomWrapper.au3" #include <INet.au3> ; set video data feed URL ;$feedURL = _INetGetSource("http://gdata.youtube.com/feeds/api/videos/HfJ91N5dzIE") ; download xml file to ;InetGet("http://gdata.youtube.com/feeds/api/videos/HfJ91N5dzIE", "videoinfo.xml", 1) ;XML file to open ;$XMLfile = $feedURL $xmlns = "xmlns:default='http://www.w3.org/2005/Atom' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'" $oXMLFile = _XMLFileOpen("subfighter.xml", $xmlns) ;$oXMLFile = _XMLFileOpen("subfighter.xml") Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch ;$array = _XMLSelectNodes('/*') $id = _GetFirstValue("/default:entry/default:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("/default:entry/default:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("/default:entry/default:updated") ConsoleWrite("Updated: " & $updated & @CRLF) For $X = 1 to _XMLGetNodeCount('/default:entry/media:group/media:thumbnail') $url = _XMLGetAttrib('/default:entry/media:group/media:thumbnail[' & $X & ']','url') ConsoleWrite($url & @CRLF) Next ;;Get the first real value returned from the _XMLGetValue() return array. REQUIRED Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1, 3, 0) EndIf EndFunc ;==>_GetFirstValue Link to comment Share on other sites More sharing options...
subfighter Posted November 12, 2008 Share Posted November 12, 2008 (edited) thanks a lot weaponx for your help as your a wizard at this. i know the documentation is very little from as i looked in the _XMLDomWrapper.au3 so without you i would of been stuck as you showed me the info I could not find or figure out and made make sense to me for the most part..THANKS AGAIN! there is the only thing i could not get to work is to get it to read the .xml using the $feedURL from the _INetGetSource as i commented out for now below. But it looks fine as it writes the XML to the console but it just gets a Parse Error when it tries to open it?expandcollapse popup;$feedURL = _INetGetSource("http://gdata.youtube.com/feeds/api/videos/sVGOrie-qxc") ;ConsoleWrite( $feedURL & @CRLF) ; Commented out as $feedURL does not work get parse error ; $oXMLFile = _XMLFileOpen($feedURL, $xmlns)oÝ÷ Øâv'¶WË^iÛhnøz§~föðØ["wënØ^^+^½êò¶§ +Ç(®·¶£ºËlyé«mæ¢÷°k+!¢é]Âäö§ÊË ë-ìjkyȵènëb~z-k¡¹^«£ 塧b¬Zn(y©Z²+p¢¹,jëh×6#include <_XMLDomWrapper.au3> #include <INet.au3> ; set video data feed URL ;$feedURL = _INetGetSource("http://gdata.youtube.com/feeds/api/videos/sVGOrie-qxc") ;ConsoleWrite( $feedURL & @CRLF) ; download xml file to InetGet("http://gdata.youtube.com/feeds/api/videos/sVGOrie-qxc", "videoinfo.xml", 1) $xmlns = 'xmlns:at="http://www.w3.org/2005/Atom" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:gd="http://schemas.google.com/g/2005"' ; Commented out as $feedURL does not work get parse error ; $oXMLFile = _XMLFileOpen($feedURL, $xmlns) $oXMLFile = _XMLFileOpen("videoinfo.xml", $xmlns) Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch $id = _GetFirstValue("//at:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("//at:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("//at:updated") ConsoleWrite("Updated: " & $updated & @CRLF) $title = _GetFirstValue("//media:title") ConsoleWrite("Title: " & $title & @CRLF) $description = _GetFirstValue("//media:description") ConsoleWrite("Description: " & $description & @CRLF) $keywords = _GetFirstValue("//media:keywords") ConsoleWrite("Keywords: " & $keywords & @CRLF) $player = _XMLGetAttrib("//media:player", "url") ConsoleWrite("Player: " & $player & @CRLF) $duration = _XMLGetAttrib("//yt:duration" , "seconds") ConsoleWrite("Duration: " & $duration & @CRLF) For $X = 1 to _XMLGetNodeCount('/at:entry/media:group/media:thumbnail') $thumbnail_url = _XMLGetAttrib('/at:entry/media:group/media:thumbnail[' & $X & ']','url') ConsoleWrite("Thumnail URL: " & $thumbnail_url & @CRLF) Next Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFunc Edited November 12, 2008 by subfighter Link to comment Share on other sites More sharing options...
weaponx Posted November 12, 2008 Share Posted November 12, 2008 Works fine for me. expandcollapse popup#include "..\_XMLDomWrapper.au3" ; set video data feed URL $feedURL = "http://gdata.youtube.com/feeds/api/videos/HfJ91N5dzIE" $localFile = "videoinfo.xml" ; download xml file to InetGet($feedURL, $localFile, 1) $xmlns = "xmlns:default='http://www.w3.org/2005/Atom' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'" $oXMLFile = _XMLFileOpen($localFile, $xmlns) ;$oXMLFile = _XMLFileOpen("subfighter.xml") Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch $id = _GetFirstValue("/default:entry/default:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("/default:entry/default:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("/default:entry/default:updated") ConsoleWrite("Updated: " & $updated & @CRLF) For $X = 1 to _XMLGetNodeCount('/default:entry/media:group/media:thumbnail') $url = _XMLGetAttrib('/default:entry/media:group/media:thumbnail[' & $X & ']','url') ConsoleWrite($url & @CRLF) Next ;;Get the first real value returned from the _XMLGetValue() return array. REQUIRED Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1, 3, 0) EndIf EndFunc ;==>_GetFirstValue Link to comment Share on other sites More sharing options...
subfighter Posted November 12, 2008 Share Posted November 12, 2008 alright now the fun part i tried doing some examples but got nowhere. As I really do not understand where to start..So we got all the VIDEO DETAILS pulled from the XML file and it works great.What i need now is i am doing a search with the YOUTUBE and getting a FEED of the results in XML. For the example here i am searching by author which is me (subfightercom) and its pulling 5 Videos from my library as i can have it get up to 50 videos at a time if you change the results variable as that is the limit YOUTUBE has on its FEED at a time.so basically i started a new SearchAuthor.au3 based off the last example that we got working. So it Downloads the File author.xml from YouTube as saves the XML file to the script directory and saves 5 videos results.so i changed the $xmlns variable like you showed me before and added the at: before the xmlns:at='http://www.w3.org/2005/Atom' so there are no problems or errors.the basic structure of the xml file is like this now<feed> <entry> VIDEO 1 DETAILS that we got from all the different Variables below </entry> <entry> VIDEO 2 DETAILS that we got from all the different Variables below </entry> <entry> VIDEO 3 DETAILS that we got from all the different Variables below </entry> <entry> VIDEO 4 DETAILS that we got from all the different Variables below </entry> </feed>i counted the _XMLGetNodeCount('/at:feed/at:entry') and it returns the proper number of 5 videos..But this is where I am lost as I need it to cycle through the 5 videos and Grab the VIDEO DETAILS we did for one video. But i do not know if do this with a loop like FOR, or an ARRAY, or the process for it to count all the entries and cycle through thementry [1] and get the VIDEO DETAILSentry [2] and get the VIDEO DETAILSentry [3] and get the VIDEO DETAILSentry [4] and get the VIDEO DETAILSentry [5] and get the VIDEO DETAILSI understand we can grab entry[1] but is there a way to get all the video details that are below for it. then [entry 2], until it reaches the end of the entry [5]any help or direction appreciated here.. expandcollapse popup#include <_XMLDomWrapper.au3> #include <INet.au3> ; DOWNLOAD XML FILE InetGet("http://gdata.youtube.com/feeds/videos?author=subfightercom&max-results=5&start-index=1", "author.xml", 1) ; OPEN XML FILE $xmlns = "xmlns:at='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'" $oXMLFile = _XMLFileOpen("author.xml", $xmlns) Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch ; COUNTS NUMBER OF VIDEOS $entry_count = _XMLGetNodeCount('/at:feed/at:entry') ConsoleWrite("Entry Count: " & $entry_count & @CRLF) ; YOUTUBE VIDEO DETAILS $id = _GetFirstValue("/at:feed/at:entry/at:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("//at:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("//at:updated") ConsoleWrite("Updated: " & $updated & @CRLF) $title = _GetFirstValue("//media:title") ConsoleWrite("Title: " & $title & @CRLF) $description = _GetFirstValue("//media:description") ConsoleWrite("Description: " & $description & @CRLF) $keywords = _GetFirstValue("//media:keywords") ConsoleWrite("Keywords: " & $keywords & @CRLF) $player = _XMLGetAttrib("//media:player", "url") ConsoleWrite("Player: " & $player & @CRLF) $duration = _XMLGetAttrib("//yt:duration" , "seconds") ConsoleWrite("Duration: " & $duration & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[1]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[2]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[3]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) $thumbnail = _XMLGetAttrib("//media:thumbnail[4]", "url") ConsoleWrite("Duration: " & $thumbnail & @CRLF) Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFuncthe xml is automatically downloaded in the example above.. but here it is also for 5 videos.. i attached it also.CODE<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'><id>http://gdata.youtube.com/feeds/videos</id><updated>2008-11-11T19:50:21.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><title type='text'>YouTube Videos</title><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link rel='alternate' type='text/html' href='http://www.youtube.com'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/batch'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos?author=subfightercom&start-index=1&max-results=5'/><link rel='next' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos?author=subfightercom&start-index=6&max-results=5'/><author><name>YouTube</name><uri>http://www.youtube.com/</uri></author><generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator><openSearch:totalResults>198</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>5</openSearch:itemsPerPage><entry><id>http://gdata.youtube.com/feeds/videos/tGml1ekv0d4</id><published>2007-11-16T15:50:09.000Z</published><updated>2008-11-11T19:50:21.000Z</updated><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Fight'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sports'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Stopped'/><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Is'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Sucker'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='After'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Punch'/><title type='text'>Sucker Punch After Fight Is Stopped</title><content type='html'><div style="color: #000000;font-family: Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; width: 555px;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="140" valign="top" rowspan="2"><div style="border: 1px solid #999999; margin: 0px 10px 5px 0px;"><a href=" alt="" src="http://i.ytimg.com/vi/tGml1ekv0d4/2.jpg"></a></div></td><td width="256" valign="top"><div style="font-size: 12px; font-weight: bold;"><a style="font-size: 15px; font-weight: bold; font-decoration: none;" href=" Punch After Fight Is Stopped</a><br></div><div style="font-size: 12px; margin: 3px 0px;"><span>Sucker Punch After Fight Is Stopped</span></div></td><td style="font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span><a href="http://www.youtube.com/profile?user=subfightercom">subfightercom</a></div><div><span style="color: #666666; font-size: 11px;">Views:</span>84901</div><div style="white-space: nowrap;text-align: left"><img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div><div style="font-size: 11px;">41<span style="color: #666666; font-size: 11px;">ratings</span></div></td></tr><tr><td><span style="color: #666666; font-size: 11px;">Time:</span><span style="color: #000000; font-size: 11px; font-weight: bold;">05:04</span></td><td style="font-size: 11px; padding-left: 20px;"><span style="color: #666666; font-size: 11px;">More in</span><a href="http://www.youtube.com/categories_portal?c=17">Sports</a></td></tr></tbody></table></div></content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=tGml1ekv0d4'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/tGml1ekv0d4/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/tGml1ekv0d4/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=tGml1ekv0d4'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/tGml1ekv0d4'/><author><name>subfightercom</name><uri>http://gdata.youtube.com/feeds/users/subfightercom</uri></author><media:group><media:title type='plain'>Sucker Punch After Fight Is Stopped</media:title><media:description type='plain'>Sucker Punch After Fight Is Stopped</media:description><media:keywords>After, Fight, Is, Punch, Stopped, Sucker</media:keywords><yt:duration seconds='304'/><media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category><media:content url='http://www.youtube.com/watch?v=tGml1ekv0d4&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='304' yt:format='5'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwne0S_p1aVptBMYDSANFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='304' yt:format='1'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwne0S_p1aVptBMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='304' yt:format='6'/><media:thumbnail url='http://i.ytimg.com/vi/tGml1ekv0d4/2.jpg' height='97' width='130' time='00:02:32'/><media:thumbnail url='http://i.ytimg.com/vi/tGml1ekv0d4/1.jpg' height='97' width='130' time='00:01:16'/><media:thumbnail url='http://i.ytimg.com/vi/tGml1ekv0d4/3.jpg' height='97' width='130' time='00:03:48'/><media:thumbnail url='http://i.ytimg.com/vi/tGml1ekv0d4/0.jpg' height='240' width='320' time='00:02:32'/><media:player url='http://www.youtube.com/watch?v=tGml1ekv0d4'/></media:group><yt:statistics viewCount='84901' favoriteCount='23'/><gd:rating min='1' max='5' numRaters='41' average='3.63'/><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/videos/tGml1ekv0d4/comments' countHint='92'/></gd:comments></entry><entry><id>http://gdata.youtube.com/feeds/videos/NFUcsznpfcM</id><published>2007-10-09T11:22:07.000Z</published><updated>2008-11-11T05:11:34.000Z</updated><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Subfighter'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sports'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Muay'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Boxing'/><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Kick'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Thai'/><title type='text'>Lewis vs Vitali Highlight (by kickyourheadoff).wmv</title><content type='html'><div style="color: #000000;font-family: Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; width: 555px;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="140" valign="top" rowspan="2"><div style="border: 1px solid #999999; margin: 0px 10px 5px 0px;"><a href=" alt="" src="http://i.ytimg.com/vi/NFUcsznpfcM/2.jpg"></a></div></td><td width="256" valign="top"><div style="font-size: 12px; font-weight: bold;"><a style="font-size: 15px; font-weight: bold; font-decoration: none;" href=" vs Vitali Highlight (by kickyourheadoff).wmv</a><br></div><div style="font-size: 12px; margin: 3px 0px;"><span>Lewis vs Vitali Highlight (by kickyourheadoff).wmv</span></div></td><td style="font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span><a href="http://www.youtube.com/profile?user=subfightercom">subfightercom</a></div><div><span style="color: #666666; font-size: 11px;">Views:</span>18283</div><div style="white-space: nowrap;text-align: left"><img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div><div style="font-size: 11px;">17<span style="color: #666666; font-size: 11px;">ratings</span></div></td></tr><tr><td><span style="color: #666666; font-size: 11px;">Time:</span><span style="color: #000000; font-size: 11px; font-weight: bold;">06:15</span></td><td style="font-size: 11px; padding-left: 20px;"><span style="color: #666666; font-size: 11px;">More in</span><a href="http://www.youtube.com/categories_portal?c=17">Sports</a></td></tr></tbody></table></div></content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=NFUcsznpfcM'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/NFUcsznpfcM/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/NFUcsznpfcM/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=NFUcsznpfcM'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/NFUcsznpfcM'/><author><name>subfightercom</name><uri>http://gdata.youtube.com/feeds/users/subfightercom</uri></author><media:group><media:title type='plain'>Lewis vs Vitali Highlight (by kickyourheadoff).wmv</media:title><media:description type='plain'>Lewis vs Vitali Highlight (by kickyourheadoff).wmv</media:description><media:keywords>Boxing, Kick, Muay, Subfighter, Thai</media:keywords><yt:duration seconds='375'/><media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category><media:content url='http://www.youtube.com/watch?v=NFUcsznpfcM&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='375' yt:format='5'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwnDfek5sxxVNBMYDSANFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='375' yt:format='1'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwnDfek5sxxVNBMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='375' yt:format='6'/><media:thumbnail url='http://i.ytimg.com/vi/NFUcsznpfcM/2.jpg' height='97' width='130' time='00:03:07.500'/><media:thumbnail url='http://i.ytimg.com/vi/NFUcsznpfcM/1.jpg' height='97' width='130' time='00:01:33.750'/><media:thumbnail url='http://i.ytimg.com/vi/NFUcsznpfcM/3.jpg' height='97' width='130' time='00:04:41.250'/><media:thumbnail url='http://i.ytimg.com/vi/NFUcsznpfcM/0.jpg' height='240' width='320' time='00:03:07.500'/><media:player url='http://www.youtube.com/watch?v=NFUcsznpfcM'/></media:group><yt:statistics viewCount='18283' favoriteCount='19'/><gd:rating min='1' max='5' numRaters='17' average='4.65'/><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/videos/NFUcsznpfcM/comments' countHint='28'/></gd:comments></entry><entry><id>http://gdata.youtube.com/feeds/videos/oUq0v5InLHc</id><published>2007-10-09T09:35:16.000Z</published><updated>2008-11-11T17:50:04.000Z</updated><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Subfighter'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sports'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Muay'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Boxing'/><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Kick'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Thai'/><title type='text'>Girls Teenage Boxing - Smoker Match.wmv</title><content type='html'><div style="color: #000000;font-family: Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; width: 555px;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="140" valign="top" rowspan="2"><div style="border: 1px solid #999999; margin: 0px 10px 5px 0px;"><a href=" alt="" src="http://i.ytimg.com/vi/oUq0v5InLHc/2.jpg"></a></div></td><td width="256" valign="top"><div style="font-size: 12px; font-weight: bold;"><a style="font-size: 15px; font-weight: bold; font-decoration: none;" href=" Teenage Boxing - Smoker Match.wmv</a><br></div><div style="font-size: 12px; margin: 3px 0px;"><span>Girls Teenage Boxing - Smoker Match.wmv</span></div></td><td style="font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span><a href="http://www.youtube.com/profile?user=subfightercom">subfightercom</a></div><div><span style="color: #666666; font-size: 11px;">Views:</span>7800</div><div style="white-space: nowrap;text-align: left"><img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div><div style="font-size: 11px;">13<span style="color: #666666; font-size: 11px;">ratings</span></div></td></tr><tr><td><span style="color: #666666; font-size: 11px;">Time:</span><span style="color: #000000; font-size: 11px; font-weight: bold;">07:34</span></td><td style="font-size: 11px; padding-left: 20px;"><span style="color: #666666; font-size: 11px;">More in</span><a href="http://www.youtube.com/categories_portal?c=17">Sports</a></td></tr></tbody></table></div></content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=oUq0v5InLHc'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/oUq0v5InLHc/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/oUq0v5InLHc/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=oUq0v5InLHc'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/oUq0v5InLHc'/><author><name>subfightercom</name><uri>http://gdata.youtube.com/feeds/users/subfightercom</uri></author><media:group><media:title type='plain'>Girls Teenage Boxing - Smoker Match.wmv</media:title><media:description type='plain'>Girls Teenage Boxing - Smoker Match.wmv</media:description><media:keywords>Boxing, Kick, Muay, Subfighter, Thai</media:keywords><yt:duration seconds='454'/><media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category><media:content url='http://www.youtube.com/watch?v=oUq0v5InLHc&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='454' yt:format='5'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwl3LCeSv7RKoRMYDSANFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='454' yt:format='1'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwl3LCeSv7RKoRMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='454' yt:format='6'/><media:thumbnail url='http://i.ytimg.com/vi/oUq0v5InLHc/2.jpg' height='97' width='130' time='00:03:47'/><media:thumbnail url='http://i.ytimg.com/vi/oUq0v5InLHc/1.jpg' height='97' width='130' time='00:01:53.500'/><media:thumbnail url='http://i.ytimg.com/vi/oUq0v5InLHc/3.jpg' height='97' width='130' time='00:05:40.500'/><media:thumbnail url='http://i.ytimg.com/vi/oUq0v5InLHc/0.jpg' height='240' width='320' time='00:03:47'/><media:player url='http://www.youtube.com/watch?v=oUq0v5InLHc'/></media:group><yt:statistics viewCount='7800' favoriteCount='27'/><gd:rating min='1' max='5' numRaters='13' average='3.92'/><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/videos/oUq0v5InLHc/comments' countHint='2'/></gd:comments></entry><entry><id>http://gdata.youtube.com/feeds/videos/_8o3HZhBHyY</id><published>2006-12-19T19:06:13.000Z</published><updated>2008-11-11T00:05:06.000Z</updated><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='DB-Darce'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sports'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Grip'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Darce'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Choke'/><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Brabo'/><title type='text'>Brabo Choke To Darce Grip Snap Back To DB-Darce Choke</title><content type='html'><div style="color: #000000;font-family: Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; width: 555px;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="140" valign="top" rowspan="2"><div style="border: 1px solid #999999; margin: 0px 10px 5px 0px;"><a href=" alt="" src="http://i.ytimg.com/vi/_8o3HZhBHyY/2.jpg"></a></div></td><td width="256" valign="top"><div style="font-size: 12px; font-weight: bold;"><a style="font-size: 15px; font-weight: bold; font-decoration: none;" href=" Choke To Darce Grip Snap Back To DB-Darce Choke</a><br></div><div style="font-size: 12px; margin: 3px 0px;"><span>Brabo Choke To Darce Grip Snap Back To DB-Darce Choke</span></div></td><td style="font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span><a href="http://www.youtube.com/profile?user=subfightercom">subfightercom</a></div><div><span style="color: #666666; font-size: 11px;">Views:</span>4839</div><div style="white-space: nowrap;text-align: left"><img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div><div style="font-size: 11px;">4<span style="color: #666666; font-size: 11px;">ratings</span></div></td></tr><tr><td><span style="color: #666666; font-size: 11px;">Time:</span><span style="color: #000000; font-size: 11px; font-weight: bold;">08:37</span></td><td style="font-size: 11px; padding-left: 20px;"><span style="color: #666666; font-size: 11px;">More in</span><a href="http://www.youtube.com/categories_portal?c=17">Sports</a></td></tr></tbody></table></div></content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=_8o3HZhBHyY'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/_8o3HZhBHyY/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/_8o3HZhBHyY/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=_8o3HZhBHyY'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/_8o3HZhBHyY'/><author><name>subfightercom</name><uri>http://gdata.youtube.com/feeds/users/subfightercom</uri></author><media:group><media:title type='plain'>Brabo Choke To Darce Grip Snap Back To DB-Darce Choke</media:title><media:description type='plain'>Brabo Choke To Darce Grip Snap Back To DB-Darce Choke</media:description><media:keywords>Brabo, Choke, Darce, DB-Darce, Grip</media:keywords><yt:duration seconds='517'/><media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category><media:content url='http://www.youtube.com/watch?v=_8o3HZhBHyY&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='517' yt:format='5'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwkmH0GYHTfK_xMYDSANFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='517' yt:format='1'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwkmH0GYHTfK_xMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='517' yt:format='6'/><media:thumbnail url='http://i.ytimg.com/vi/_8o3HZhBHyY/2.jpg' height='97' width='130' time='00:04:18.500'/><media:thumbnail url='http://i.ytimg.com/vi/_8o3HZhBHyY/1.jpg' height='97' width='130' time='00:02:09.250'/><media:thumbnail url='http://i.ytimg.com/vi/_8o3HZhBHyY/3.jpg' height='97' width='130' time='00:06:27.750'/><media:thumbnail url='http://i.ytimg.com/vi/_8o3HZhBHyY/0.jpg' height='240' width='320' time='00:04:18.500'/><media:player url='http://www.youtube.com/watch?v=_8o3HZhBHyY'/></media:group><yt:statistics viewCount='4839' favoriteCount='54'/><gd:rating min='1' max='5' numRaters='4' average='4.00'/><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/videos/_8o3HZhBHyY/comments' countHint='2'/></gd:comments></entry><entry><id>http://gdata.youtube.com/feeds/videos/hCjDwTGjDIY</id><published>2007-10-09T09:08:28.000Z</published><updated>2008-11-05T06:05:53.000Z</updated><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Matches'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Closed'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Door'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sports'/><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='MMA'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='BJJ'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='NHB'/><title type='text'>The Underground Fight Clubs 1996.flv</title><content type='html'><div style="color: #000000;font-family: Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; width: 555px;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="140" valign="top" rowspan="2"><div style="border: 1px solid #999999; margin: 0px 10px 5px 0px;"><a href=" alt="" src="http://i.ytimg.com/vi/hCjDwTGjDIY/2.jpg"></a></div></td><td width="256" valign="top"><div style="font-size: 12px; font-weight: bold;"><a style="font-size: 15px; font-weight: bold; font-decoration: none;" href=" Underground Fight Clubs 1996.flv</a><br></div><div style="font-size: 12px; margin: 3px 0px;"><span>The Underground Fight Clubs 1996.flv</span></div></td><td style="font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;" width="146" valign="top"><div><span style="color: #666666; font-size: 11px;">From:</span><a href="http://www.youtube.com/profile?user=subfightercom">subfightercom</a></div><div><span style="color: #666666; font-size: 11px;">Views:</span>2714</div><div style="white-space: nowrap;text-align: left"><img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> <img style="border: 0px none; margin: 0px; padding: 0px; vertical-align: middle; font-size: 11px;" align="top" alt="" src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div><div style="font-size: 11px;">8<span style="color: #666666; font-size: 11px;">ratings</span></div></td></tr><tr><td><span style="color: #666666; font-size: 11px;">Time:</span><span style="color: #000000; font-size: 11px; font-weight: bold;">07:24</span></td><td style="font-size: 11px; padding-left: 20px;"><span style="color: #666666; font-size: 11px;">More in</span><a href="http://www.youtube.com/categories_portal?c=17">Sports</a></td></tr></tbody></table></div></content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=hCjDwTGjDIY'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/hCjDwTGjDIY/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/hCjDwTGjDIY/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=hCjDwTGjDIY'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/videos/hCjDwTGjDIY'/><author><name>subfightercom</name><uri>http://gdata.youtube.com/feeds/users/subfightercom</uri></author><media:group><media:title type='plain'>The Underground Fight Clubs 1996.flv</media:title><media:description type='plain'>The Underground Fight Clubs 1996.flv</media:description><media:keywords>BJJ, Closed, Door, Matches, MMA, NHB</media:keywords><yt:duration seconds='444'/><media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category><media:content url='http://www.youtube.com/watch?v=hCjDwTGjDIY&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='444' yt:format='5'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwmGDKMxwcMohBMYDSANFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='444' yt:format='1'/><media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwmGDKMxwcMohBMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='444' yt:format='6'/><media:thumbnail url='http://i.ytimg.com/vi/hCjDwTGjDIY/2.jpg' height='97' width='130' time='00:03:42'/><media:thumbnail url='http://i.ytimg.com/vi/hCjDwTGjDIY/1.jpg' height='97' width='130' time='00:01:51'/><media:thumbnail url='http://i.ytimg.com/vi/hCjDwTGjDIY/3.jpg' height='97' width='130' time='00:05:33'/><media:thumbnail url='http://i.ytimg.com/vi/hCjDwTGjDIY/0.jpg' height='240' width='320' time='00:03:42'/><media:player url='http://www.youtube.com/watch?v=hCjDwTGjDIY'/></media:group><yt:statistics viewCount='2714' favoriteCount='7'/><gd:rating min='1' max='5' numRaters='8' average='3.50'/><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/videos/hCjDwTGjDIY/comments' countHint='9'/></gd:comments></entry></feed>author.xml Link to comment Share on other sites More sharing options...
weaponx Posted November 12, 2008 Share Posted November 12, 2008 You do this just like when you loop through media:thumbnail. I feel like you are taking two steps forward and one step back. For $V = 1 to _XMLGetNodeCount('//at:entry') ; YOUTUBE VIDEO DETAILS $id = _GetFirstValue("//at:entry[" & $V & "]/at:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("//at:entry[" & $V & "]/at:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("//at:entry[" & $V & "]/at:updated") ConsoleWrite("Updated: " & $updated & @CRLF) $title = _GetFirstValue("//at:entry[" & $V & "]/media:title") ConsoleWrite("Title: " & $title & @CRLF) $description = _GetFirstValue("//at:entry[" & $V & "]/media:description") ConsoleWrite("Description: " & $description & @CRLF) $keywords = _GetFirstValue("//at:entry[" & $V & "]/media:keywords") ConsoleWrite("Keywords: " & $keywords & @CRLF) $player = _XMLGetAttrib("//at:entry[" & $V & "]/media:player", "url") ConsoleWrite("Player: " & $player & @CRLF) $duration = _XMLGetAttrib("//at:entry[" & $V & "]/yt:duration" , "seconds") ConsoleWrite("Duration: " & $duration & @CRLF) For $X = 1 to _XMLGetNodeCount("//at:entry[" & $V & "]/media:group/media:thumbnail") $url = _XMLGetAttrib("//at:entry[" & $V & "]/media:group/media:thumbnail[" & $X & "]","url") ConsoleWrite($url & @CRLF) Next Next Link to comment Share on other sites More sharing options...
subfighter Posted November 12, 2008 Share Posted November 12, 2008 well what threw me off is getting the values with a different xmlns: instead having //at:entry for all of them.. Then it made sense to me. What Is there a difference between b]//at:entry with 2 slashes and b]/at:entry with one slashAlso when we put the //at:entry what does the /at: actually stand for? Is that using the xmlns:at='http://www.w3.org/2005/Atom as the format to parse the file.thanks again weaponx as your good at this and for anyone that needs an example just load the script below as it grabs the .xml from YOUTUBE and hopefully helps you out as weaponx showed me the light. now time to make a gui for this expandcollapse popup#include <_XMLDomWrapper.au3> #include <INet.au3> ; DOWNLOAD XML FILE InetGet("http://gdata.youtube.com/feeds/videos?author=subfightercom&max-results=15&start-index=1", "author.xml", 1) ; OPEN XML FILE $xmlns = "xmlns:at='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'" $oXMLFile = _XMLFileOpen("author.xml", $xmlns) Switch @error Case 0 ConsoleWrite("No Error" & @CRLF) Case 1 ConsoleWrite("Parse Error" & @CRLF) Case 2 ConsoleWrite("No Object" & @CRLF) EndSwitch ; COUNTS NUMBER OF VIDEOS $entry_count = _XMLGetNodeCount('/at:feed/at:entry') ConsoleWrite("Entry Count: " & $entry_count & @CRLF) For $V = 1 to _XMLGetNodeCount('//at:entry') ; YOUTUBE VIDEO DETAILS $id = _GetFirstValue("//at:entry[" & $V & "]/at:id") ConsoleWrite("Id: " & $id & @CRLF) $published = _GetFirstValue("//at:entry[" & $V & "]/at:published") ConsoleWrite("Published: " & $published & @CRLF) $updated = _GetFirstValue("//at:entry[" & $V & "]/at:updated") ConsoleWrite("Updated: " & $updated & @CRLF) $title = _GetFirstValue("//at:entry[" & $V & "]/media:group/media:title") ConsoleWrite("Title: " & $title & @CRLF) $description = _GetFirstValue("//at:entry[" & $V & "]/media:group/media:description") ConsoleWrite("Description: " & $description & @CRLF) $keywords = _GetFirstValue("//at:entry[" & $V & "]/media:group/media:keywords") ConsoleWrite("Keywords: " & $keywords & @CRLF) $player = _XMLGetAttrib("//at:entry[" & $V & "]/media:group/media:player", "url") ConsoleWrite("Player: " & $player & @CRLF) $duration = _XMLGetAttrib("//at:entry[" & $V & "]/media:group/yt:duration" , "seconds") ConsoleWrite("Duration: " & $duration & @CRLF) For $X = 1 to _XMLGetNodeCount("//at:entry[" & $V & "]/media:group/media:thumbnail") $thumbnailurl = _XMLGetAttrib("//at:entry[" & $V & "]/media:group/media:thumbnail[" & $X & "]","url") ConsoleWrite($thumbnailurl & @CRLF) Next ConsoleWrite("Processed: " & $V & @CRLF) Sleep(2000) ;2 seconds Next Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFunc Link to comment Share on other sites More sharing options...
weaponx Posted November 12, 2008 Share Posted November 12, 2008 This is the best XML reference I have found:http://www.w3schools.com/xpath/xpath_syntax.aspThese are pretty much the same:'//at:feed/at:entry'and'/at:entry'The single slash assumes you are matching inside of the root node.I think the only reason we have to use the default namespace workaround is due to limitations in the MSXML2 object. Eltorro said he was working on a new version of this UDF that uses a different XML object, which may work differently. Link to comment Share on other sites More sharing options...
toxicvn Posted December 7, 2008 Share Posted December 7, 2008 link die Link to comment Share on other sites More sharing options...
wraithdu Posted December 8, 2008 Share Posted December 8, 2008 Yes, looks like the whole site is down. Can anyone post the latest version of the UDF + example file? Thanks! Link to comment Share on other sites More sharing options...
wraithdu Posted December 9, 2008 Share Posted December 9, 2008 (edited) EDIT, n/m, found eltorro's google code page with the latest version, whew.http://code.google.com/p/my-autoit/Hmm, I could still use the latest example script though, it's not posted on the google code page. Edited December 9, 2008 by wraithdu Link to comment Share on other sites More sharing options...
sanchopanza Posted December 9, 2008 Share Posted December 9, 2008 Hi I want to get the linenumber where an error occurs when the xml file is parsed and it has errors. I tried $objDoc.parseError.line but it returns always 0. Has anyone an idea how I can get the linenumber ? thanks sanchopanza Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now