0

我有一个非常大的 xml。它有字段喜欢

<SegrigatedQualification>
    <EducationSplit>
      <University><![CDATA[G. H. Raisoni College of Engineering]]></University>
      <Degree><![CDATA[Engineering]]></Degree>
      <Year><![CDATA[2011]]></Year>
    </EducationSplit>
    <EducationSplit>
      <University><![CDATA[G. H. Raisoni College of Engineering]]></University>
      <Degree><![CDATA[Engineering]]></Degree>
      <Year><![CDATA[2010]]></Year>
    </EducationSplit>
    <EducationSplit>
      <University><![CDATA[G. H. Raisoni College of Engineering]]></University>
      <Degree><![CDATA[Engineering]]></Degree>
      <Year><![CDATA[2009]]></Year>
    </EducationSplit>
    <EducationSplit>
      <University><![CDATA[Diploma  I.T]]></University>
      <Degree><![CDATA[Diploma  I.T]]></Degree>
      <Year><![CDATA[2008]]></Year>
    </EducationSplit>
    <EducationSplit>
      <University><![CDATA[Nasik Board]]></University>
      <Degree><![CDATA[S.S.C]]></Degree>
      <Year><![CDATA[2003]]></Year>
    </EducationSplit>
  </SegrigatedQualification>

我想映射字段并制作表格,然后将所有xml的信息存储到表格中。问题是如果我创建一个列 SagrigratedQualificaton 我如何存储教育拆分或大学、学位、年份?因为如果我创建单独的列,大学、学位等的信息将占用两行或更多行,这样表格就会变得多余。将 xml 映射到表中的最佳方法是什么?

4

3 回答 3

0

关系数据库...每个 xml 结构应该是不同表中的不同记录。或者只是保持简单并将其存储在某个 TEXT 或 BLOB 字段中。

于 2012-12-21T06:26:28.337 回答
0

您可以使用 MagicParser 之类的工具来提取数据,然后轻松地将其映射到您自己的表和字段中。

于 2012-12-21T06:31:28.707 回答
0
<?php
require("MagicParser.php");

function myRecordHandler($record){


// This is where you write your code to process each record, such as loading a database

// The following code will print out each field in your sample data:
print $record["EDUCATIONSPLIT"];
print $record["UNIVERSITY"];
print $record["DEGREE"];
print $record["YEAR"];
}

$data = ""; // string variable contianing the data to parse

MagicParser_parse("string://".$data,"myRecordHandler","xml|SEGRIGATEDQUALIFICATION/EDUCATIONSPLIT/");
?>

注意:如果您想从实际文件中加载它,那么您只需删除 $data 引用并使 MagicParser_parse 如下所示:

MagicParser_parse("your-xml-file.xml".$data,"myRecordHandler","xml|SEGRIGATEDQUALIFICATION/EDUCATIONSPLIT/");
于 2012-12-21T06:55:57.077 回答