SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2013
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Parse XML file using PHP

    Hi,

    I have XML file and I want to parse XML file and store aggregates and other data into database.

    Any idea how to achive this using PHP.


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resultSet>
    	<timePeriod>
    		<period>date_range</period>
    		<startDate>20100312</startDate>
    		<endDate>20140331</endDate>
    		<startTime>1268380800</startTime>
    		<endTime>1396335599</endTime>
    		<label>03/12/2010 - 03/31/2014</label>
    	</timePeriod>
    
    	<aggregates>
    		<metric name="visitDuration" value="10" label="Avg. Visit Duration"/>
    		<metric name="bounces" value="4" label="Bounces"/>
    		<metric name="repeatVisitors" value="3" label="Repeat Visitors"/>
    		<metric name="newVisitors" value="1" label="New Visitors"/>
    		<metric name="visits" value="5" label="Visits"/>
    		<metric name="pageViews" value="13" label="Page Views"/>
    	</aggregates>
    
    	<resultsTotal>4</resultsTotal>
    	<resultsReturned>4</resultsReturned>
    	<resultsPerPage>25</resultsPerPage>
    	<resultsRows>
    		<row>
    			<dimension name="date" value="20140302" label="Date"/>
    			<dimension name="browserType" value="Chrome" label="Browser Type"/>
    			<dimension name="country" value="united states" label="Country"/>
    			<metric name="visitDuration" value="0" label="Avg. Visit Duration"/>
    			<metric name="bounces" value="1" label="Bounces"/>
    			<metric name="repeatVisitors" value="1" label="Repeat Visitors"/>
    			<metric name="newVisitors" value="0" label="New Visitors"/>
    			<metric name="visits" value="1" label="Visits"/>
    			<metric name="pageViews" value="1" label="Page Views"/>
    		</row>
    		<row>
    			<dimension name="date" value="20140302" label="Date"/>
    			<dimension name="browserType" value="Firefox" label="Browser Type"/>
    			<dimension name="country" value="united states" label="Country"/>
    			<metric name="visitDuration" value="0" label="Avg. Visit Duration"/>
    			<metric name="bounces" value="1" label="Bounces"/>
    			<metric name="repeatVisitors" value="1" label="Repeat Visitors"/>
    			<metric name="newVisitors" value="0" label="New Visitors"/>
    			<metric name="visits" value="1" label="Visits"/>
    			<metric name="pageViews" value="1" label="Page Views"/>
    		</row>
    		<row>
    			<dimension name="date" value="20140302" label="Date"/>
    			<dimension name="browserType" value="Other" label="Browser Type"/>
    			<dimension name="country" value="united states" label="Country"/>
    			<metric name="visitDuration" value="0" label="Avg. Visit Duration"/>
    			<metric name="bounces" value="1" label="Bounces"/>
    			<metric name="repeatVisitors" value="1" label="Repeat Visitors"/>
    			<metric name="newVisitors" value="0" label="New Visitors"/>
    			<metric name="visits" value="1" label="Visits"/>
    			<metric name="pageViews" value="1" label="Page Views"/>
    		</row>
    		<row>
    			<dimension name="date" value="20140303" label="Date"/>
    			<dimension name="browserType" value="Chrome" label="Browser Type"/>
    			<dimension name="country" value="united states" label="Country"/>
    			<metric name="visitDuration" value="25" label="Avg. Visit Duration"/>
    			<metric name="bounces" value="1" label="Bounces"/>
    			<metric name="repeatVisitors" value="1" label="Repeat Visitors"/>
    			<metric name="newVisitors" value="1" label="New Visitors"/>
    			<metric name="visits" value="2" label="Visits"/>
    			<metric name="pageViews" value="10" label="Page Views"/>
    		</row>
    	</resultsRows>
    </resultSet>

    -Thanks

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2013
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •