使用XMLReader解析大型XML

时间:2013-07-10 14:59:23

标签: php mysql xml xmlreader

我正在尝试使用XMLReader解析一个大型XML,但我正在圈子里。 有没有办法让我获得所有的价值并将其插入数据库?

我需要获取所有值,包括属性。这可能吗?

非常感谢任何帮助!!!

XML中的文件示例:

<?xml version="1.0"?>
<Extract>
  <EBook EAN="789795431321">
    <Title>Title 1</Title>
    <SubTitle>Subtitle</SubTitle>
    <Publisher>General Non-Fiction</Publisher>
    <Imprint>Publisher</Imprint>
    <PublicationDate>07/04/2011</PublicationDate>
    <Contributors>
      <Contributor Code="A01" Text="By (author)">Author 1</Contributor>
    </Contributors>
    <BicSubjects>
      <Bic Code="PDZ">Popular science</Bic>
    </BicSubjects>
    <Formats>
      <Format Type="6" Price="7.00" MaxDownloads="3" Status="active" ExclusiveRights="CA AU NZ ZA GB IE " NotForSale="AU NZ " />
    </Formats>
    <ShortDescription>LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIps </ShortDescription>
    <PhysicalEditionEan>9898526588</PhysicalEditionEan>
  </EBook>
  <EBook EAN="97858524656">
    <Title>Title 2</Title>
    <Publisher>Publisher 2</Publisher>
    <Imprint>Print it</Imprint>
    <PublicationDate>04/09/2008</PublicationDate>
    <Contributors>
      <Contributor Code="A01" Text="By (author)">Random, Name</Contributor>
    </Contributors>
    <BicSubjects>
      <Bic Code="FV">Historical fiction</Bic>
    </BicSubjects>
    <Formats>
      <Format Type="6" Price="7.99" MaxDownloads="3" Status="active" ExclusiveRights="AD AE AF AG AI AL AM AN AO AQ AR AS AT AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CS CU CV CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR ST SV SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT YU ZA ZM ZW " />
    </Formats>
    <ShortDescription>LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum </ShortDescription>
    <PhysicalEditionEan>9780230529663</PhysicalEditionEan>
  </EBook>

0 个答案:

没有答案