<legend id='2eWA2'><style id='2eWA2'><dir id='2eWA2'><q id='2eWA2'></q></dir></style></legend>

<small id='2eWA2'></small><noframes id='2eWA2'>

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

      <tfoot id='2eWA2'></tfoot>

        • <bdo id='2eWA2'></bdo><ul id='2eWA2'></ul>

        为什么使用 XML 解析器?

        Why use an XML parser?(为什么使用 XML 解析器?)
      1. <legend id='7W5aJ'><style id='7W5aJ'><dir id='7W5aJ'><q id='7W5aJ'></q></dir></style></legend>
        <i id='7W5aJ'><tr id='7W5aJ'><dt id='7W5aJ'><q id='7W5aJ'><span id='7W5aJ'><b id='7W5aJ'><form id='7W5aJ'><ins id='7W5aJ'></ins><ul id='7W5aJ'></ul><sub id='7W5aJ'></sub></form><legend id='7W5aJ'></legend><bdo id='7W5aJ'><pre id='7W5aJ'><center id='7W5aJ'></center></pre></bdo></b><th id='7W5aJ'></th></span></q></dt></tr></i><div id='7W5aJ'><tfoot id='7W5aJ'></tfoot><dl id='7W5aJ'><fieldset id='7W5aJ'></fieldset></dl></div>

        1. <small id='7W5aJ'></small><noframes id='7W5aJ'>

              <bdo id='7W5aJ'></bdo><ul id='7W5aJ'></ul>
              <tfoot id='7W5aJ'></tfoot>

                    <tbody id='7W5aJ'></tbody>

                  本文介绍了为什么使用 XML 解析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是一个有点经验丰富的 PHP 脚本编写者,但我只是深入解析 XML 和所有这些好东西.

                  I'm a somewhat experienced PHP scripter, however I just dove into parsing XML and all that good stuff.

                  我似乎无法理解为什么要使用单独的 XML 解析器而不是仅使用 explode 函数,这似乎同样简单.这是我一直在做的事情(假设路径 xml.php 处有一个有效的 XML 文件):

                  I just can't seem to wrap my head around why one would use a separate XML parser instead of just using the explode function, which seems to be just as simple. Here's what I've been doing (assuming there is a valid XML file at the path xml.php):

                  $contents = file_get_contents("xml.php");
                  $array1 = explode("<a_tag>", $contents);
                  $array2 = explode("</a_tag>", $array1[1]);
                  $data = $array2[0];
                  

                  所以我的问题是,如果您可以将值分成数组并从中提取数据,那么 XML 解析器的实际用途是什么?

                  So my question is, what is the practical use for an XML parser if you can just separate the values into arrays and extract the data from that point?

                  提前致谢!:)

                  推荐答案

                  简而言之,它的一致性.在 XML 广泛使用之前,有许多未记录的格式用于将信息保存在文件中.XML 背后的动机之一是创建定义明确的标准文档格式.有了这种明确定义的格式,就可以开发一套通用的解析工具,只要文档遵守上述明确定义的格式,就可以在文档上始终如一地工作.

                  In a nutshell, its consistency. Before XML came into wide use there were numerous undocumented formats for keeping information in files. One of the motivators behind XML was to create a well defined, standard document format. With this well defined format in place, a general set of parsing tools could be developed that would work consistently on documents so long as the documents adhered to the aforementioned well defined format.

                  在某些特定情况下,您的示例代码会起作用.但是,如果文档发生变化

                  In some specific cases, your example code will work. However, if the document changes

                  ...
                  <!-- adding an attribute -->
                  <a_tag foo="bar">Contents of the Tag</a_tag>
                  ...
                  
                  ...
                  <!-- adding a comment to the contents -->
                  <a_tag>Contents <!-- foobar --> of the Tag</a_tag>
                  ...
                  

                  您的解析代码可能会中断.使用正确定义的 XML 解析器编写的代码不会.

                  Your parsing code will probably break. Code written using a correctly defined XML parser will not.

                  这篇关于为什么使用 XML 解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

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

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

                  1. <tfoot id='lCHWS'></tfoot>
                  2. <legend id='lCHWS'><style id='lCHWS'><dir id='lCHWS'><q id='lCHWS'></q></dir></style></legend>

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