| trying to parse XML file trying to parse XML file |
drooh

msg:4423287 | 9:58 pm on Feb 29, 2012 (gmt 0) | not sure what Im doing wrong here, this works for just about every feed out there? $xml = simplexml_load_file("http://alzheimersanddementia.org/current.rss"); $result = $xml->xpath("/rss/channel/item"); print_R($result); // prints nothing The problem is I do not know what to put in the $xml->xpath(""); Any Ideas
|
incrediBILL

msg:4423422 | 2:26 am on Mar 1, 2012 (gmt 0) | Not sure what's going on exactly but xpath doesn't seem to like that file, makes it crash even! For staters, it's not an RSS, it's an RDF internally, so try this and you get one result: $xml = simplexml_load_file("http://alzheimersanddementia.org/current.rss"); $result = $xml->xpath("/rdf:RDF"); print_R($result); // prints something However, $xml->xpath("/rdf:RDF/channel"); doesn't work for no obvious reason
|
incrediBILL

msg:4423425 | 2:53 am on Mar 1, 2012 (gmt 0) | I got curious so I copied their file over to my server and made an edit, changing "<rdf:RDF" and "</rdf:RDF" in the document to just "<rdf " and "</rdf>" made it all works just fine. Easy workaround to load the file into a string first, do a string replace of "rdf:RDF" to just "rdf" and then convert it to a simple XML object. xpath, like many PHP functions, is just a buggy bunch of ... It's free, get what you pay for.
|
drooh

msg:4423791 | 7:31 pm on Mar 1, 2012 (gmt 0) | For some reason, i just tried that but I dont know what you mean convert to simple XML oblect this is what Im doing <? $content = file_get_contents('http://alzheimersanddementia.org/current.rss'); $content = str_replace('rdf:RDF','rdf',$content); file_put_contents('/home/anewdaya/public_html/news.xml', $content); ?> Then Im trying this $xml = simplexml_load_file("/home/anewdaya/public_html/news.xml"); $result = $xml->xpath("/rdf/channel/item"); print_R($result); But still nothing?
|
incrediBILL

msg:4423902 | 12:08 am on Mar 2, 2012 (gmt 0) | Try simplifying the problem, did you get '/rdf' to work? or '/rdf/channel'? I did with the test file I made, but I chopped out a LOT of content to simplify the file. The original file appears to be valid but it causes issues with xpath for some reason, so you need to step into it and debug the thing bit by bit until you find out the cause. If there are any other ':'s in the xml tag names, that seems to be one show stopper. Also make sure your code really wrote the file, sometimes PHP can't write to the public_html area without changing the directory permissions.
|
|
|