Solved

SimpleXML Query

Posted on 2014-10-24
1
102 Views
Last Modified: 2014-10-24
Hi,

I am using SimpleXML to take the data from the sample XML below.

How do I extract the Value of CL 1266 by specifically search against Nummer="5"

<WinsApp>
  <Import>
    <ManipulationCtx>
      <Akt>
        <AktPr>
          <AktDaten>
            <AktChiffre Nummer="3">Technisch</AktChiffre>

            <AktChiffre Nummer="5">CL 1266</AktChiffre>

            <AktChiffre Nummer="9">FRA (FRANKFURT MAIN - FRANKFURT)</AktChiffre>
            <AktChiffre Nummer="10">GRZ (GRAZ  - GRAZ)</AktChiffre>
            <AktChiffre Nummer="4">20.05.2012</AktChiffre>
            <AktChiffre Nummer="11">22:10:00</AktChiffre>
            <AktChiffre Nummer="12">20.05.2012</AktChiffre>
            <AktChiffre Nummer="13">23:25:00</AktChiffre>
            <AktChiffre Nummer="28">O</AktChiffre>
          </AktDaten>
        <AktPr>
      <Akt>
    <ManipulationCtx>
  <Import>
<WinsApp>

Thanks

James
0
Comment
Question by:booneball
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40402316
$xml = <<<XML
<?xml version='1.0'?>
 <WinsApp>
   <Import>
     <ManipulationCtx>
       <Akt>
         <AktPr>
           <AktDaten>
             <AktChiffre Nummer="3">Technisch</AktChiffre>

             <AktChiffre Nummer="5">CL 1266</AktChiffre>

             <AktChiffre Nummer="9">FRA (FRANKFURT MAIN - FRANKFURT)</AktChiffre>
             <AktChiffre Nummer="10">GRZ (GRAZ  - GRAZ)</AktChiffre>
             <AktChiffre Nummer="4">20.05.2012</AktChiffre>
             <AktChiffre Nummer="11">22:10:00</AktChiffre>
             <AktChiffre Nummer="12">20.05.2012</AktChiffre>
             <AktChiffre Nummer="13">23:25:00</AktChiffre>
             <AktChiffre Nummer="28">O</AktChiffre>
           </AktDaten>
         </AktPr>
       </Akt>
     </ManipulationCtx>
   </Import>
 </WinsApp>
XML;

$xml = new SimpleXMLElement($xml);

$p = $xml->xpath('//AktChiffre[@Nummer="3"]');
echo $p[0];

Open in new window

0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question