if ($format == "json" || $format == "xml") {
     # Open folder
     $dir = opendir($thedir);
     $xmlresponse = "";
     $jsonresponse = "";
     $i = 0;
     while ($file = readdir($dir)) {
         if ($file != "." and $file != "..") {
             $thepath = $dir . "/" . $file;
             $xml = file_get_contents($thedir . $file);
             $searchfield = $xml;
             if (strlen($field) > 0) {
                 $searchfield = value_in($field, $xml);
             }
             $title = value_in('title', $xml);
             $abstract = value_in('abstract', $xml);
             if (stristr($searchfield, $search)) {
                 $jsonresponse .= '{"row":{"title":"' . $title . '", "abstract":"' . urlencode($abstract) . '", "file_name":"' . urlencode($file) . '"}},';
                 $xmlresponse .= '<row><column name="title">' . $title . '</column><column name="abstract">' . $abstract . '</column><column name="file_name">' . $file . '</column></row>';
                 $i++;
             }
         }
     }
     if ($i > 1) {
         $xmlresponse .= "</rows>";
         $xmlresponse = '<rows total-rows="' . $i . '">' . $xmlresponse;
         $jsonresponse .= "]}";
         $jsonresponse = '{"total_rows":"' . $i . '","rows":[' . $jsonresponse;
     } else {
         $xmlresponse = '<rows total-rows="0"/>';
         $jsonresponse = '{"total_rows":"0","rows":"row"}';
Example #2
0
            $data = str_replace("<prism:publicationName>", "<publicationName>", $data);
            $data = str_replace("</prism:publicationName>", "</publicationName>", $data);
            $data = str_replace("<prism:issn>", "<issn>", $data);
            $data = str_replace("</prism:issn>", "</issn>", $data);
            $data = str_replace("<prism:volume>", "<volume>", $data);
            $data = str_replace("</prism:volume>", "</volume>", $data);
            $data = str_replace("<prism:number>", "<number>", $data);
            $data = str_replace("</prism:number>", "</number>", $data);
            $data = str_replace("<prism:startingPage>", "<startingPage>", $data);
            $data = str_replace("</prism:startingPage>", "</startingPage>", $data);
            $data = str_replace("<prism:endingPage>", "<endingPage>", $data);
            $data = str_replace("</prism:endingPage>", "</endingPage>", $data);
            $data = str_replace("<prism:publicationDate>", "<publicationDate>", $data);
            $data = str_replace("</prism:publicationDate>", "</publicationDate>", $data);
            $data = str_replace('<content type="text">', "<content>", $data);
            $salida = "\tforma.titulo.value=\"" . value_in("title", value_in("entry", $data)) . "\";\n\t\t\t\t\t\t\tforma.autores.value=\"" . value_in("name", value_in("author", $data)) . "\";\n\t\t\t\t\t\t\tforma.anno.value=\"" . value_in("publicationDate", $data) . "\";\n\t\t\t\t\t\t\tforma.volumen.value=\"" . value_in("volume", $data) . "\";\n\t\t\t\t\t\t\tforma.numero.value=\"" . value_in("number", $data) . "\";\n\t\t\t\t\t\t\tforma.paginas.value=\"" . value_in("startingPage", $data) . "-" . value_in("endingPage", $data) . "\";\n\t\t\t\t\t\t\tforma.resumen.value=\"" . value_in("content", $data) . "\";\n\t\t\t\t";
            break;
        default:
    }
    echo $salida;
}
function value_in($element_name, $xml, $content_only = true)
{
    if ($xml == false) {
        return false;
    }
    $found = preg_match('#<' . $element_name . '(?:\\s+[^>]+)?>(.*?)' . '</' . $element_name . '>#s', $xml, $matches);
    if ($found != false) {
        if ($content_only) {
            return $matches[1];
            //ignore the enclosing tags
//$entries = $doc->getElementsByTagName("gsx:projecttitle");
//if ($entries->length > 0) {
//	foreach($entries as $e) {
//		echo $e;
//	}
//}
$items = element_set('entry', $xml);
$c = 1;
foreach ($items as $i) {
    $content = value_in('gsx:projecttitle', $i);
    $name = value_in('gsx:fullnamesanddegreese.g.johne.smithmdphd', $i);
    $contact = value_in('gsx:nrnbcontact', $i);
    echo "<tr><td>" . $c++ . "<td>{$content}<td>{$name}<td>{$contact}</tr>";
}
$title = value_in('title', $xml);
$link = value_in('link', $xml);
function value_in($element_name, $xml, $content_only = true)
{
    if ($xml == false) {
        return false;
    }
    $found = preg_match('#<' . $element_name . '(?:\\s+[^>]+)?>(.*?)' . '</' . $element_name . '>#s', $xml, $matches);
    if ($found != false) {
        if ($content_only) {
            return $matches[1];
            //ignore the enclosing tags
        } else {
            return $matches[0];
            //return the full pattern match
        }
    }
function getBlogFromAtomFeed($xml, $url)
{
    $blog = array('title' => value_in('title', $xml), 'entries' => array());
    $entries = element_set('entry', $xml);
    if ($entries === NULL || $entries === false) {
        throw new Exception("XML parse error: could not find post entries; check your feed URL and make sure it is publicly accessible.  You should be able to see your posts here: {$url}");
    }
    foreach ($entries as $entry) {
        $tags = array();
        $cats = element_set('category', $entry);
        if (!empty($cats)) {
            foreach ($cats as $cat) {
                $category = element_attributes('category', $cat);
                // Blogger puts tags in reverse order, so prepend like a queue
                // instead of pushing like a stack.  (Not that order really matters,
                // but some people might care.)
                array_unshift($tags, unhtmlentities($category['term']));
            }
        }
        // Check for summary.  Blogger only includes summary if content isn't.
        $entry_body = unhtmlentities(value_in('content', $entry));
        $entry_summary = value_in('summary', $entry);
        if (empty($entry_body) && !empty($entry_summary)) {
            throw new HtmlSafeException("It looks like your blog's feed settings are only showing summaries, and this is preventing me from seeing your full posts.  Change your <a href=\"http://www.google.com/support/blogger/bin/answer.py?hl=en&amp;answer=42662\" target=\"_blank\">blog posts feed settings</a> to \"Full\".");
        }
        $blog['entries'][] = array('title' => unhtmlentities(value_in('title', $entry)), 'timestamp' => date('Y-m-d H:i:s', strtotime(value_in('published', $entry))), 'body' => $entry_body, 'tags' => $tags);
    }
    return $blog;
}