Xml - 试图获取非对象的属性

时间:2012-07-03 04:03:39

标签: xml

如果我的XML文件与普通文件略有不同,我如何解决XML ... 这是我正在使用的XML文件......

<?xml version="1.0" encoding="utf-8"?>

<pma_xml_export version="1.0" xmlns:pma="http://www.phpmyadmin.net/some_doc_url/">
    <!--
    - Structure schemas
    -->
    <pma:structure_schemas>
        <pma:database name="pet shop" collation="utf8_general_ci" charset="utf8">
            <pma:table name="markers">
                CREATE TABLE `markers` (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `name` varchar(60) NOT NULL,
                  `address` varchar(80) NOT NULL,
                  `lat` float(10,6) NOT NULL,
                  `lng` float(10,6) NOT NULL,
                  `type` varchar(30) NOT NULL,
                  PRIMARY KEY (`id`)
                ) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
            </pma:table>
        </pma:database>
    </pma:structure_schemas>

    <!--
    - Database: 'pet shop'
    -->
    <database name="pet shop">
        <!-- Table markers -->
        <table name="markers">
            <column name="id">1</column>
            <column name="name">Pan Africa Market</column>
            <column name="address">1521 1st Ave, Seattle, WA</column>
            <column name="lat">47.608940</column>
            <column name="lng">-122.340141</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">2</column>
            <column name="name">Buddha Thai &amp; Bar</column>
            <column name="address">2222 2nd Ave, Seattle, WA</column>
            <column name="lat">47.613590</column>
            <column name="lng">-122.344391</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">3</column>
            <column name="name">The Melting Pot</column>
            <column name="address">14 Mercer St, Seattle, WA</column>
            <column name="lat">47.624561</column>
            <column name="lng">-122.356445</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">4</column>
            <column name="name">Ipanema Grill</column>
            <column name="address">1225 1st Ave, Seattle, WA</column>
            <column name="lat">47.606365</column>
            <column name="lng">-122.337654</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">5</column>
            <column name="name">Sake House</column>
            <column name="address">2230 1st Ave, Seattle, WA</column>
            <column name="lat">47.612823</column>
            <column name="lng">-122.345673</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">6</column>
            <column name="name">Crab Pot</column>
            <column name="address">1301 Alaskan Way, Seattle, WA</column>
            <column name="lat">47.605961</column>
            <column name="lng">-122.340363</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">7</column>
            <column name="name">Mama's Mexican Kitchen</column>
            <column name="address">2234 2nd Ave, Seattle, WA</column>
            <column name="lat">47.613976</column>
            <column name="lng">-122.345467</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">8</column>
            <column name="name">Wingdome</column>
            <column name="address">1416 E Olive Way, Seattle, WA</column>
            <column name="lat">47.617214</column>
            <column name="lng">-122.326584</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">9</column>
            <column name="name">Piroshky Piroshky</column>
            <column name="address">1908 Pike pl, Seattle, WA</column>
            <column name="lat">47.610126</column>
            <column name="lng">-122.342834</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">10</column>
            <column name="name">Pan Africa Market</column>
            <column name="address">1521 1st Ave, Seattle, WA</column>
            <column name="lat">47.608940</column>
            <column name="lng">-122.340141</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">11</column>
            <column name="name">Buddha Thai &amp; Bar</column>
            <column name="address">2222 2nd Ave, Seattle, WA</column>
            <column name="lat">47.613590</column>
            <column name="lng">-122.344391</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">12</column>
            <column name="name">The Melting Pot</column>
            <column name="address">14 Mercer St, Seattle, WA</column>
            <column name="lat">47.624561</column>
            <column name="lng">-122.356445</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">13</column>
            <column name="name">Ipanema Grill</column>
            <column name="address">1225 1st Ave, Seattle, WA</column>
            <column name="lat">47.606365</column>
            <column name="lng">-122.337654</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">14</column>
            <column name="name">Sake House</column>
            <column name="address">2230 1st Ave, Seattle, WA</column>
            <column name="lat">47.612823</column>
            <column name="lng">-122.345673</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">15</column>
            <column name="name">Crab Pot</column>
            <column name="address">1301 Alaskan Way, Seattle, WA</column>
            <column name="lat">47.605961</column>
            <column name="lng">-122.340363</column>
            <column name="type">restaurant</column>
        </table>
        <table name="markers">
            <column name="id">16</column>
            <column name="name">Mama's Mexican Kitchen</column>
            <column name="address">2234 2nd Ave, Seattle, WA</column>
            <column name="lat">47.613976</column>
            <column name="lng">-122.345467</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">17</column>
            <column name="name">Wingdome</column>
            <column name="address">1416 E Olive Way, Seattle, WA</column>
            <column name="lat">47.617214</column>
            <column name="lng">-122.326584</column>
            <column name="type">bar</column>
        </table>
        <table name="markers">
            <column name="id">18</column>
            <column name="name">Piroshky Piroshky</column>
            <column name="address">1908 Pike pl, Seattle, WA</column>
            <column name="lat">47.610126</column>
            <column name="lng">-122.342834</column>
            <column name="type">restaurant</column>
        </table>
    </database>
</pma_xml_export>

那么,我怎样才能提取lat和lng

1 个答案:

答案 0 :(得分:0)

六月承诺 -

感谢您澄清编程语言(PHP)和IDE(Netbeans 7.1)。

听起来你最好的选择是:

  1. 使用PHP和XPath从XML文件中读取纬度和经度:

  2. 使用PHP和PDO保存到数据库: