How to parse the following xml using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thulaseeram
    New Member
    • Sep 2006
    • 23

    How to parse the following xml using php

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap: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">
    <soap:Header><t:ServerVersionInfo MajorVersion="8" MinorVersion="1" MajorBuildNumber="436" MinorBuildNumber="0" 
    
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
    </soap:Header>
    <soap:Body>
    <m:FindItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
    
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
    <m:ResponseMessages>
    <m:FindItemResponseMessage ResponseClass="Success">
    <m:ResponseCode>NoError</m:ResponseCode>
    
    <m:RootFolder TotalItemsInView="1" IncludesLastItemInRange="true">
    <t:Items>
    <t:CalendarItem>
    <t:ItemId 
    <t:Subject>Test data</t:Subject>
    <t:Start>2010-07-16T11:00:00Z</t:Start>
    <t:End>2010-07-16T11:01:00Z</t:End>
    </t:CalendarItem></t:Items></m:RootFolder></m:FindItemResponseMessage></m:ResponseMessages></m:FindItemResponse></soap:Body><
    
    /soap:Envelope>
    I tried to get the data by using the following and is not returning any data

    Code:
      $objDOM = new DOMDocument();
      if (!$objDOM->load("calendar.xml")) { Return 400; }else{
      	$calbody = $objDOM->getElementsByTagName("t:CalendarItem");
      
      	print_r($calbody);
      }

    please help me how to get he data from the above xml
    Last edited by Dormilich; Jul 15 '10, 11:06 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it didn’t work, because you didn’t respect the XML namespace. that requires its own methods: getElementsByTa gNameNS()

    Comment

    • thulaseeram
      New Member
      • Sep 2006
      • 23

      #3
      Hi,

      It helped me a lot. Thank you.

      Thanks
      Ram

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        PHP also has its own SOAP class …

        Comment

        Working...