从xml数据中获取文本而不使用domxpath

时间:2015-03-04 08:09:15

标签: php xml dom

我已将所有xml数据存储到名为“Content”的单个列的单个单元格中,这里是数据

xml数据:

<?xml version="1.0" encoding="UTF-8"?>
<records>

<record>
    <language>eng</language>
    <publisher>Molecular Diversity Preservation International</publisher>
    <journalTitle>Dentistry Journal</journalTitle>
    <eissn>2304-6767</eissn>
    <publicationDate>2012-06-19</publicationDate>
    <volume>1</volume>
    <issue>1</issue>
            <startPage>1</startPage>
    <endPage>2</endPage>
            <doi>10.3390/dj1010001</doi>                <publisherRecordId>dj1010001</publisherRecordId>
    <documentType>article</documentType>
    <title language="eng">
Dentistry ― At the Heart of Conflict between Medicine and Technology</title>
    <authors>
                <author>
            <name>Claude Jaquiery</name>
            <email>jaquieryc@uhbs.ch</email>
                            <affiliationId>1</affiliationId>
                        </author>
            </authors>
    <affiliationsList>
                <affiliationName affiliationId="1">Department of Cranio-    Maxillofacial Surgery and Hightech Research Center, University Hospital Basel, Spitalstrasse 21, 4031 Basel, Switzerland</affiliationName>
            </affiliationsList>
    <abstract language="eng">As the first Editor-in-Chief of Dentistry Journal, I would like to provide a few comments about this field of research and practice. Evolved from a purely technical profession, dentists are nowadays exposed to a variety of different challenges. [...]</abstract>
    <fullTextUrl format="pdf">http://www.mdpi.com/2304-6767/1/1/1</fullTextUrl>
    <keywords language="eng">
                <keyword>n/a</keyword>
            </keywords>
</record>
<record>
    <language>eng</language>
    <publisher>Multidisciplinary Digital Publishing Institute</publisher>
    <journalTitle>Dentistry Journal</journalTitle>
    <eissn>2304-6767</eissn>
    <publicationDate>2012-12-21</publicationDate>
    <volume>1</volume>
    <issue>1</issue>
            <startPage>3</startPage>
    <endPage>11</endPage>
            <doi>10.3390/dj1010003</doi>            <publisherRecordId>dj1010003</publisherRecordId>
    <documentType>article</documentType>
    <title language="eng">Color Parameters of the Chromascop Shade Guide</title>
    <authors>
                <author>
            <name>William J. O&#039;Brien</name>
            <email>ohws@umich.edu</email>
                            <affiliationId>1</affiliationId>
                        </author>
                <author>
            <name>Won-Suk Oh</name>
            <email>ohws@umich.edu</email>
                            <affiliationId>1</affiliationId>
                        </author>
                <author>
            <name>Peter W. Piché</name>
            <email>drppiche@gmail.com</email>
                            <affiliationId>2</affiliationId>
                        </author>
            </authors>
    <affiliationsList>
                <affiliationName affiliationId="1">Dept of Biologic &amp; Materials Sciences, University of Michigan School of Dentistry, 1011 North University, Ann Arbor, MI 48109, USA</affiliationName>
                <affiliationName affiliationId="2">Private Practice, 335 E State St Traverse City, MI 49684, USA</affiliationName>
            </affiliationsList>
    <abstract language="eng">The purposes of this study are: (1) determine the color of the twenty shades in the Ivoclar’s Chromascop shade guide, (2) determine the color representation of the shade guide described as coverage error (CE), and (3) compare this shade guide with the Vita Classical and Bioform shade guides. The spectral data was collected using Beckman model DU reflectance spectrophotometer equipped with an integrating sphere. Commission International de l’Eclairage (CIE) chromaticity coordinates were calculated using CIE illuminant C and 1931 observer data, then converted to CIE L*a*b* and Munsell notation. Each shade was spectrophotometrically compared to the published colors of 335 human teeth. The minimum CIE L*a*b* color difference was calculated for each tooth and the average of these color differences was defined as the CE. The measured colors of the Chromascop guide had a CIE L* range of 79.67 to 65.61, an a* range of -0.71 to 3.85, and a b* range of 14.58 to 27.69. The average CE of the Chromascop shade guide was 3.38. The Chromascop shade guide has similar colors and a CE compared with the Bioform and Vita Classical shade guides, but with some shades of higher red and yellow components.</abstract>
    <fullTextUrl format="pdf">http://www.mdpi.com/2304-6767/1/1/3</fullTextUrl>
    <keywords language="eng">
                <keyword>tooth color</keyword>
                <keyword> Chromascop shade guide</keyword>
                <keyword>coverage error</keyword>
            </keywords>
    </record>
</records>

以下是我想如何从上面的xml数据中获取文本到div:

php代码:

while($runrows = mysqli_fetch_assoc($getquery))
{

$id = $runrows['id'];
$name = $runrows['name'];

 $content = $runrows['content'];//this contains all xml data corresponds to each id 

 $doc = new DOMDocument();
$doc->loadXML("$content");
  foreach($doc->children() as $book)
  {    
   echo $language = $book->record[0]->language;
   $journalTitle = $book->record[0]->journalTitle;
  $publicationDate = $book->record[0]->publicationDate;
  }


echo "<div  > 
id :&nbsp;$id<br>
filename :&nbsp;$name<br>
echo  $language." <br />";
echo $journalTitle ." <br />";
echo $publicationDate ." <br />";
echo "</div>";
 }

我想直接从存储在我的数据库中的内容中获取文本而不使用domxpath这是可能的.. ??

0 个答案:

没有答案