Graxeon Posted February 5, 2009 Share Posted February 5, 2009 This is part of my code: $node = $sxml->sf:mediapath; But when I run my script, I get an error saying unexpected : for that specific line. Any ideas on how to fix that? (I tried replacing ":" with "%3A" but then I got a T_STRING error) Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/ Share on other sites More sharing options...
sKunKbad Posted February 5, 2009 Share Posted February 5, 2009 if sf is a namespace, then it needs to be declared. SimpleXML will do this for you if you check out the docs. Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-755025 Share on other sites More sharing options...
Graxeon Posted February 5, 2009 Author Share Posted February 5, 2009 Well..."sf:media" is just a tag in a RSS/XML file. <rss> <playlist> <item> <sf:media>Hello World</sf:media> </item> </playlist> </rss> So how can I get it so it doesn't give me the error message? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-755524 Share on other sites More sharing options...
Graxeon Posted February 6, 2009 Author Share Posted February 6, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756214 Share on other sites More sharing options...
premiso Posted February 6, 2009 Share Posted February 6, 2009 I am not sure that <sf:media> is a valid name for a tag....I am no XML expert, but maybe reading up on: http://www.w3.org/TR/REC-xml/#NT-Name and http://www.w3.org/TR/REC-xml/#sec-starttags1 Are you creating this RSS feed, or are you pulling it from somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756229 Share on other sites More sharing options...
Graxeon Posted February 6, 2009 Author Share Posted February 6, 2009 Thanks for the links...I'm not much of a PHP expert so I may have a hard time with it xD I am pulling the contents of sf:media from a file. If anyone else can give me an exact answer...I'd be very thankful . But...I hope those links will do Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756274 Share on other sites More sharing options...
premiso Posted February 6, 2009 Share Posted February 6, 2009 Thanks for the links...I'm not much of a PHP expert so I may have a hard time with it xD I am pulling the contents of sf:media from a file. If anyone else can give me an exact answer...I'd be very thankful . But...I hope those links will do Did you create the feed, or was the feed created from another source? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756291 Share on other sites More sharing options...
Graxeon Posted February 6, 2009 Author Share Posted February 6, 2009 I created it...why? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756328 Share on other sites More sharing options...
premiso Posted February 6, 2009 Share Posted February 6, 2009 I created it...why? I do not think it is valid XML Syntax, hence why you are getting the error. I would read up more on proper XML syntax. :media, I think should be an attribute: <sf type="media">Here </sf> Or look into namespaces as suggested above. Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756330 Share on other sites More sharing options...
Graxeon Posted February 7, 2009 Author Share Posted February 7, 2009 Does it matter what it's called? Because even though it is invalid it can still be read by other scripts if those scripts use the same tag. Umm...as for the name space thing...the 2 pages you gave me were confusing... Example...what is this? lol: ::= ('"' [^"]* '"') | ("'" [^']* "'") Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756494 Share on other sites More sharing options...
Graxeon Posted February 7, 2009 Author Share Posted February 7, 2009 Can someone help me further, please? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-756774 Share on other sites More sharing options...
Graxeon Posted February 8, 2009 Author Share Posted February 8, 2009 hello? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757121 Share on other sites More sharing options...
Graxeon Posted February 8, 2009 Author Share Posted February 8, 2009 Ok...here's the RSS file and also a new code that should work but doesn't (it's a little different from the one that I provided earlier) : <rss version="2.0"> <sf:configuration> <sf:siteurl>http://domain.com/</sf:siteurl> <sf:sitename>Domain</sf:sitename> <sf:font>IMPACT</sf:font> <sf:fontsize>20</sf:fontsize> <sf:logo/> <sf:logoalpha>50</sf:logoalpha> <sf:share>true</sf:share> <sf:upload>true</sf:upload> <sf:borderstyle>0x000000</sf:borderstyle> <sf:backgroundstyle>null</sf:backgroundstyle> <sf:textcolor>0x000000</sf:textcolor> <sf:objectcolor>0x000000</sf:objectcolor> <sf:buttoncolor>0x00cccc</sf:buttoncolor> <sf:backgroundcolor>0x000000</sf:backgroundcolor> <sf:analytics_key>UA-187186-1</sf:analytics_key> <sf:video_analytics_key>123456</sf:video_analytics_key> </sf:configuration> <ad_sys_spec aggregate_views_per_user="10" view_frequency="3"/> <ad_spec id="0" desc="empty" startdate="01012008" enddate="12312020" views_per_user="1000" overlay_provider="OVERLAY_PROVIDER" overlay_channel_id="OVERLAY_CHANNEL_ID"> <selection> <channel> <title> Welcome Video </title> \r <description/> \r <link>http://domain.com/</link> \r − <image> <url>http://domain.com/footer.jpg/url> <link>http://domain.com</link> <title>Welcome</title> <height>41</height> <width>210</width> </image> <language>en-us</language> <pubdate>Sat, 07 Feb 2009 21:37:56 GMT</pubdate> \r <playlist sort="1" orderby="1"> <item> \r <title> Welcome Video </title> \r <author>Admin</author> \r <pubDate>Tue, 14 Oct 2008 15:37:00 GMT</pubDate> \r <link> http://domain.com/welcome.html </link> \r <description> Welcome Video </description> \r <media:text type="html"> Welcome Video<br /><br /><img src="http://domain.com/image.jpg" border="0" /> </media:text> \r <media:player url="http://domain.com/welcome.html"/> \r <media:content url="http://domain.com/player.swf?=" type="application/x-shockwave-flash" medium="video" height="352" width="428" duration="220"/> \r <media:title> Welcome Video </media:title> \r <media:keywords/> \r <media:description> Welcome Video </media:description> \r <media:thumbnail url="http://domain.com/thumb.jpg" height="150" width="200"/> \r <guid isPermaLink="true" url="http://domain.com/" guid="welcome.html"/> \r <sf:kudos curmonth="0" month="0" total="0"/> <sf:avatar> http://domain.com/image.jpg </sf:avatar> \r <sf:mediapath> http://domain.com/welcome.flv </sf:mediapath> \r <sf:mediaid>954392</sf:mediaid> \r <sf:views>3649</sf:views> \r <sf:dateadded_verbose>October 14, 2008</sf:dateadded_verbose> </item> </playlist> \r </channel> </selection> </ad_spec> </rss> And this is the code that should be able to call the contents within "sf:media" ...but I can't get it to work: **Note: http://domain.com/feed-~input~ is the RSS code above--^ <?php $allowed_url = array("welcome", //Welcome video "blankspothere"); $passed_url = $_GET['url']; foreach ($allowed_url as $allowed) { if(stristr($allowed, $passed_url) !== false) { $url='http://domain.com/feed-'.$_GET['url']; $sxml = simplexml_load_file($url); list($node) = $sxml->xpath('/rss/ad_spec/selection/channel/playlist/item/sf:mediapath'); header('Location: '.$node['url']); exit; } } header("Location: http://www.google.com/"); ?> Does this information help? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757168 Share on other sites More sharing options...
sKunKbad Posted February 8, 2009 Share Posted February 8, 2009 OK, you should have looked at NAMESPACES better, because sf IS a namespace. Take a look at http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/ for more info about namespaces. You can also use getDocNamespaces() or getNamespaces(), and here is more info on it: http://www.w3schools.com/php/func_simplexml_getdocnamespaces.asp http://www.w3schools.com/php/func_simplexml_getnamespaces.asp Also see the php manual (but there are no examples). As soon as you declare the namespaces the corrent way, you will be able to start parsing those elements. Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757190 Share on other sites More sharing options...
Graxeon Posted February 8, 2009 Author Share Posted February 8, 2009 I'm a little lost...I got this from one of the links you gave me: <?php $feed = simplexml_load_file('http://www.sitepoint.com/recent.rdf'); foreach ($feed->item as $item) { $ns_dc = $item->children('http://purl.org/dc/elements/1.1/'); echo $ns_dc->date; } ?> $feed would be replaced by my feed. Then it's saying to take each of the items within the feed and extract the date after the "dc" namespace. However...what does "http://purl.org/dc/elements/1.1/" have to do with anything? That script itself works perfectly...but I don't understand how I should alter it and implement that idea into my script: <?php $allowed_url = array("welcome", //Welcome video "blankspothere"); $passed_url = $_GET['url']; foreach ($allowed_url as $allowed) { if(stristr($allowed, $passed_url) !== false) { $url='http://domain.com/feed-'.$_GET['url']; $sxml = simplexml_load_file($url); list($node) = $sxml->xpath('/rss/ad_spec/selection/channel/playlist/item/sf:mediapath'); header('Location: '.$node['url']); exit; } } header("Location: http://www.google.com/"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757442 Share on other sites More sharing options...
Graxeon Posted February 8, 2009 Author Share Posted February 8, 2009 Does anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757780 Share on other sites More sharing options...
sKunKbad Posted February 9, 2009 Share Posted February 9, 2009 To get at your sf namespace elements, you need to replace dc with sf. http://purl.org/dc/elements/1.1/ is the description of the dc namespace, but looking at your xml, you might need to get at the sf namespace through the getNamespace function. This URI is kinda like a description of what is inside the sf namespace, and what form of data is there. BTW, the XML that you shared does not look valid. Where did you get it? Maybe if you can share the source, and hook me up with the URI, I'll try to parse it for you. Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-757933 Share on other sites More sharing options...
Graxeon Posted February 11, 2009 Author Share Posted February 11, 2009 I'm not sure what you mean...but this is the link that a friend gave me: http://animecongeries.vidiac.com/handlers/SFAsysPlayer_GetData.ashx?playerinfo={ mode:%27stdvideo_from_id%27, video:%274e5eaaba-deed-4e1f-bde6-9b35010174d2 Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-759978 Share on other sites More sharing options...
Graxeon Posted February 12, 2009 Author Share Posted February 12, 2009 Skunk, you there? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-760730 Share on other sites More sharing options...
Graxeon Posted February 13, 2009 Author Share Posted February 13, 2009 Hellooo Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-761546 Share on other sites More sharing options...
Graxeon Posted February 14, 2009 Author Share Posted February 14, 2009 I guess you're away . Can someone else help me, please? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-762111 Share on other sites More sharing options...
Graxeon Posted February 15, 2009 Author Share Posted February 15, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/143873-error-for-simple-xml-element/#findComment-762485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.