Home Backend Development PHP Tutorial 用php读取xml soap,该怎么处理

用php读取xml soap,该怎么处理

Jun 13, 2016 pm 01:31 PM
amp gt lt quot soap

用php读取xml soap
我又遇到一个难题,请高手帮我解决一下

有个xml文件,格式比较奇怪,也许我从来没有接触过这种文件吧

XML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?xml version="1.0" encoding="utf-8"?>
<envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<body>
<queryresponse xmlns="http://tempuri.org/">
<queryresult>
Order_flag=0&Name_num=2077&StartCity=SZX&EndCity=PEK&Dates=2012-5-31&.......后面还有好多这样的数据。
</queryresult>
</queryresponse>
</body>
</envelope>


Copy after login


这种文件怎么读取呀?

------解决方案--------------------
把它当xml 用simplexml解析
PHP code
<?php $soap=<<<SOAP
<?xml version="1.0" encoding="utf-8"?>
<envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<body>
<queryresponse xmlns="http://tempuri.org/">
<queryresult>
Order_flag=0&Name_num=2077&StartCity=SZX&EndCity=PEK&Dates=2012-5-31&.......后面还有好多这样的数据。
</queryresult>
</queryresponse>
</body>
</envelope>
SOAP;

$xml=simplexml_load_string($soap);
$result = $xml->children('http://schemas.xmlsoap.org/soap/envelope/')
    ->children('http://tempuri.org/')
    ->QueryResponse
    ->QueryResult;

echo $result;
//Order_flag=0&Name_num=2077&StartCity=SZX&EndCity=PEK&Dates=2012-5-31&.......后面还有好多这样的数据。 <div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

How to use PHP and SOAP to implement Web service invocation and development How to use PHP and SOAP to implement Web service invocation and development Jun 25, 2023 am 09:59 AM

In the field of Web development, Web services are a very important technology that enable different applications to communicate with each other to build more complex and powerful systems. In this article, we will take an in-depth look at how to use PHP and SOAP to implement web service invocation and development. SOAP (SimpleObjectAccessProtocol) is an XML-based protocol used for information exchange between different applications. SOAP is an important Web service standard

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

PHP and SOAP: How to Implement Remote Procedure Calls (RPC) PHP and SOAP: How to Implement Remote Procedure Calls (RPC) Jul 29, 2023 pm 02:45 PM

PHP and SOAP: How to implement Remote Procedure Call (RPC) Introduction: In recent years, with the rise of distributed systems, Remote Procedure Call (RPC) has been widely adopted in Web development. This article will introduce how to implement RPC using PHP and SOAP, and demonstrate its usage through code examples. 1. What is remote procedure call (RPC)? Remote procedure call (RemoteProcedureCall, RPC) is a communication

PHP and SOAP: How to achieve synchronous and asynchronous processing of data PHP and SOAP: How to achieve synchronous and asynchronous processing of data Jul 28, 2023 pm 03:29 PM

PHP and SOAP: How to implement synchronous and asynchronous processing of data Introduction: In modern web applications, synchronous and asynchronous processing of data are becoming more and more important. Synchronous processing refers to processing only one request at a time and waiting for the completion of the request before processing the next request; asynchronous processing refers to processing multiple requests at the same time without waiting for the completion of a certain request. In this article, we will introduce how to use PHP and SOAP to achieve synchronous and asynchronous processing of data. 1. Introduction to SOAP SOAP (SimpleObject

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

Parsing SOAP messages using Python Parsing SOAP messages using Python Aug 08, 2023 am 09:27 AM

Parsing SOAP messages using Python SOAP (Simple Object Access Protocol) is an XML-based remote procedure call (RPC) protocol used to communicate between different applications on the network. Python provides many libraries and tools to process SOAP messages, the most commonly used of which is the suds library. suds is a SOAP client library for Python that can be used to parse and generate SOAP messages. It provides a simple and

SOAP Protocol Guide in PHP SOAP Protocol Guide in PHP May 20, 2023 pm 07:10 PM

With the continuous development of Internet technology, more and more enterprise-level applications need to provide interfaces to other applications to realize the interaction of data and business. In this case, we need a reliable protocol to transmit data and ensure data integrity and security. SOAP (Simple Object Access Protocol) is an XML-based protocol that can be used to implement communication between applications in a Web environment. As a popular web programming language, PHP

See all articles