PHP-将XML/RDF转换为HTML

PHP-将XML/RDF转换为HTML,php,html,xml,rdf,Php,Html,Xml,Rdf,在此URL上: <!-- /////////////////////////////////////////////////////////////////////////////////////// // // Annotation properties // ///////////////////////////////////////////////////////////////////////////////////////

在此URL上:

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>
当我用Chrome检查元素时,我可以看到HTML:

<div xmlns="http://www.w3.org/1999/xhtml" id="mainbody">
      <link href="http://www.ontobee.org/public/css/ontology.css" rel="stylesheet" type="text/css" />
      <script src="http://www.ontobee.org/public/js/ontobee.ontology.js"></script>
      <h3 class="title">
        <a href="http://www.ontobee.org/ontology/HP"> human phenotype ontology</a>
      </h3>
      <form action="http://www.ontobee.org/search" method="get" id="keyword-search">
        <input name="ontology" id="ontology" type="hidden" value="HP" />
        <div class="ui-widget">
          <strong>
            <label for="keywords">Keywords: </label>
          </strong>
          <input id="keywords" name="keywords" size="30" />
          <input type="submit" name="submit" value="Search terms" />
        </div>
      </form>
      <p class="section-title">
  Class: <span class="section-title-value">Striae distensae</span></p>
      <div class="iri">...
    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>


关键词:

类别:远纹

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>
...
我看到了HTML,但当我查看源代码时,我得到了XML:

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>

我需要一种通过编程将RDF/XML转换为HTML的方法。有没有简单的方法可以做到这一点?我需要找到他们的XML转换文件吗

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>

注意:我之所以需要这样做是因为我需要下载一批这些文档。我需要搜集数据。他们有一个SPARQAPI,但我已经写了一个scraper,认为我所看到的是一个HTML文档,我很少从头到尾写一些东西而不在编写过程中进行测试,但这一次出于某种原因我这么做了。必须有一种方法通过浏览器插件来实现,因为浏览器能够输出HTML。

页面上的RDF用于显示的类。因此,不,您无法从RDF设计页面的HTML

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>

如果您正在查找页面本身的HTML,那么从浏览器的inspect工具获取HTML会更容易。

问题是我需要获取大量这些页面。也许有一个chrome或firefox插件可以让我下载页面列表的成批HTML。让我直截了当地说:你正在以机器可处理的结构化格式(RDF/XML)返回数据,但你希望它转换为人类可读的格式(HTML),这样你就可以。。。将其刮除,使其变回结构化/机器可处理的状态?我知道你在意识到自己的错误之前就已经开始了这项工作,但即使如此,放弃你的scraper并编写一个简单的RDF处理客户端可能还是更有效的(从长远来看当然更好)。是的,我有点超前,在测试之前编写了整个脚本,每个细节。通常,我会边走边测试。你说得对,我应该放弃剧本。解析XML应该相对容易,这是可行的,但使用实际的RDF库(如EasyRDF)可能更容易。谢谢。当我开始做这件事时,这可能会帮我省下很多麻烦。我真的很了解RDF。
    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>
    <AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasDbXref"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#inSubset"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasAlternativeId"/>
    <AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"/>