<tfoot id='qPWhi'></tfoot>

      <small id='qPWhi'></small><noframes id='qPWhi'>

        <legend id='qPWhi'><style id='qPWhi'><dir id='qPWhi'><q id='qPWhi'></q></dir></style></legend>

        <i id='qPWhi'><tr id='qPWhi'><dt id='qPWhi'><q id='qPWhi'><span id='qPWhi'><b id='qPWhi'><form id='qPWhi'><ins id='qPWhi'></ins><ul id='qPWhi'></ul><sub id='qPWhi'></sub></form><legend id='qPWhi'></legend><bdo id='qPWhi'><pre id='qPWhi'><center id='qPWhi'></center></pre></bdo></b><th id='qPWhi'></th></span></q></dt></tr></i><div id='qPWhi'><tfoot id='qPWhi'></tfoot><dl id='qPWhi'><fieldset id='qPWhi'></fieldset></dl></div>

        • <bdo id='qPWhi'></bdo><ul id='qPWhi'></ul>

        SimpleXML:使用包含命名空间的 XML

        时间:2024-05-11
        • <bdo id='Wy3Hr'></bdo><ul id='Wy3Hr'></ul>

          1. <i id='Wy3Hr'><tr id='Wy3Hr'><dt id='Wy3Hr'><q id='Wy3Hr'><span id='Wy3Hr'><b id='Wy3Hr'><form id='Wy3Hr'><ins id='Wy3Hr'></ins><ul id='Wy3Hr'></ul><sub id='Wy3Hr'></sub></form><legend id='Wy3Hr'></legend><bdo id='Wy3Hr'><pre id='Wy3Hr'><center id='Wy3Hr'></center></pre></bdo></b><th id='Wy3Hr'></th></span></q></dt></tr></i><div id='Wy3Hr'><tfoot id='Wy3Hr'></tfoot><dl id='Wy3Hr'><fieldset id='Wy3Hr'></fieldset></dl></div>

            <tfoot id='Wy3Hr'></tfoot><legend id='Wy3Hr'><style id='Wy3Hr'><dir id='Wy3Hr'><q id='Wy3Hr'></q></dir></style></legend>
              <tbody id='Wy3Hr'></tbody>
            • <small id='Wy3Hr'></small><noframes id='Wy3Hr'>

                • 本文介绍了SimpleXML:使用包含命名空间的 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试通过 google-picasa API 获取地理信息.这是原始 XML:

                  I am trying to get to the geo information off the google-picasa API. This is the original XML:

                  <georss:where>
                    <gml:Point>
                      <gml:pos>35.669998 139.770004</gml:pos>
                    </gml:Point>
                  </georss:where>
                  

                  我已经走到这一步了,有:

                  I already have come this far, with:

                  $ns_geo=$item->children($namespace['georss']);
                  $geo=$ns_geo->children($namespace['gml']);
                  

                  var_dump($geo) 会输出

                  object(SimpleXMLElement)#34 (1) { 
                    ["Point"]=> object(SimpleXMLElement)#30 (1) { 
                      ["pos"]=> string(18) "52.373801 4.890935" 
                    } 
                  } 
                  

                  但是

                  echo (string)$geo->position or (string)$geo->position->pos; 
                  

                  不会给我任何东西.有什么明显的我做错了吗?

                  will give me nothing. Is there something obvious that i am doing wrong?

                  推荐答案

                  您可以使用 XPath 和 registerXPathNamespace():

                  You could work with XPath and registerXPathNamespace():

                  $xml->registerXPathNamespace("georss", "http://www.georss.org/georss");
                  $xml->registerXPathNamespace("gml", "http://www.opengis.net/gml");
                  $pos = $xml->xpath("/georss:where/gml:Point/gml:pos");
                  

                  从文档中,强调我的:

                  registerXPathNamespace […] 为下一个 XPath 查询创建一个前缀/ns 上下文.

                  registerXPathNamespace […] Creates a prefix/ns context for the next XPath query.

                  更多在 SimpleXML 中处理命名空间的方法可以在这里找到,例如:
                  Stuart Herbert 在 PHP - 使用 SimpleXML解析 RSS 源

                  More ways to handle namespaces in SimpleXML can be found here, for example:
                  Stuart Herbert On PHP - Using SimpleXML To Parse RSS Feeds

                  这篇关于SimpleXML:使用包含命名空间的 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用“root"php的命名空间? 下一篇:如何获取特定命名空间内的所有类名?

                  相关文章

                • <small id='XSd7u'></small><noframes id='XSd7u'>

                  1. <legend id='XSd7u'><style id='XSd7u'><dir id='XSd7u'><q id='XSd7u'></q></dir></style></legend>

                  2. <tfoot id='XSd7u'></tfoot>
                      <bdo id='XSd7u'></bdo><ul id='XSd7u'></ul>

                    <i id='XSd7u'><tr id='XSd7u'><dt id='XSd7u'><q id='XSd7u'><span id='XSd7u'><b id='XSd7u'><form id='XSd7u'><ins id='XSd7u'></ins><ul id='XSd7u'></ul><sub id='XSd7u'></sub></form><legend id='XSd7u'></legend><bdo id='XSd7u'><pre id='XSd7u'><center id='XSd7u'></center></pre></bdo></b><th id='XSd7u'></th></span></q></dt></tr></i><div id='XSd7u'><tfoot id='XSd7u'></tfoot><dl id='XSd7u'><fieldset id='XSd7u'></fieldset></dl></div>