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

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

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

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

      1. 使用 SimpleXML 获取属性和值

        Get attributes and values using SimpleXML(使用 SimpleXML 获取属性和值)

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

              <tbody id='nqLNQ'></tbody>
            <tfoot id='nqLNQ'></tfoot>

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

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

                • <bdo id='nqLNQ'></bdo><ul id='nqLNQ'></ul>
                • 本文介绍了使用 SimpleXML 获取属性和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我真的不明白如何在 PHP 中使用 SimpleXML.

                  I really don't understand how to use SimpleXML in PHP.

                  这是我的 XML 文件的示例:

                  Here is an exemple of my XML file:

                  <?xml version="1.0" encoding="UTF-8" ?>
                  <eventlog version="1.1">
                  
                  <event source="Firewall" timeStamp="1308433939" type="0" deleted="0" bodyLength="218">
                  <subject>Network access detected</subject>
                  <action>Allowed</action>
                  <message>The program c:xamppapacheinhttpd.exe attempted to connect to the Internet. The program used the protocol TCP on port 80.</message>
                  </event>
                  
                  </eventlog>
                  

                  我需要检索这个:来源、时间戳、主题、操作、消息

                  I need to retrieve this: Source, Timestamp, Subject, Action, Message

                  我只是不明白.有人可以帮我解决这个问题吗?

                  I just don't get it. Can someone please help me with this?

                  推荐答案

                  这段代码应该可以工作:

                  This code should work:

                  $xml = new SimpleXMLElement($xmlString);
                  $source = $xml->event->attributes()->source;
                  $timestamp = $xml->event->attributes()->timestamp;
                  $subject = $xml->event->subject;
                  $action = $xml->event->action;
                  $message = $xml->event->message;
                  

                  ... 其中 $xmlString 是 xml 文件的字符串.

                  ... where $xmlString is the string of the xml file.

                  阅读如何使用 simpleXML这里.

                  Read up on how to use simpleXML here.

                  希望这会有所帮助,祝你好运!

                  Hope this helped and good luck!

                  这篇关于使用 SimpleXML 获取属性和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Converting string to MySQL timestamp format in php(在php中将字符串转换为MySQL时间戳格式)
                  datetime to timestamp(日期时间到时间戳)
                  PHP timestamp date to user timezone(PHP时间戳日期到用户时区)
                  Converting TIMESTAMP to unix time in PHP?(在 PHP 中将 TIMESTAMP 转换为 unix 时间?)
                  Convert ISO 8601 to unixtimestamp(将 ISO 8601 转换为 unixtimestamp)
                  Finding days between 2 unix timestamps in php(在php中查找2个unix时间戳之间的天数)

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

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

                        • <legend id='iwBti'><style id='iwBti'><dir id='iwBti'><q id='iwBti'></q></dir></style></legend>

                              <tbody id='iwBti'></tbody>