Sedang Disiapkan

PHP XML help needed

Hello

I'm trying for the last 2 days, with 2 hours sleep, and viewing hundreds of forums, to achieve this :

XMl data

<postid>1</postid>

<posttitle>post title 1</posttitle>

<date>2012-01-01</date>

<postmeta>

<meta_key>Banner1URLforpost1</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner2URLforpost1</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner3URLforpost1</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postid>1</postid>

<posttitle>post title 2</posttitle>

<date>2012-01-01</date>

<postmeta>

<meta_key>Banner1URLforpost22/meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner2URLforpost2</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner3URLforpost2</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postid>1</postid>

<posttitle>post title 3</posttitle>

<date>2012-01-01</date>

<postmeta>

<meta_key>Banner1URLforpost3</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner2URLforpost3</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

<postmeta>

<meta_key>Banner3URLforpost3</meta_key>

<meta_value>[url removed, login to view]</meta_value>

</postmeta>

Now, my PHP looks something like this :

<?php

// displays all the file nodes

if(!$xml=simplexml_load_file('[url removed, login to view]')){

trigger_error('Error reading XML file',E_USER_ERROR);

}

echo 'Displaying contents of XML file...<br />';

foreach($xml as $item){

echo 'postid: '.$item->postid.'<br>';

echo 'posttitle: '.$item->posttitle.'<br>';

echo 'date: '.$item->date.'<br>';

echo '<br><br>';

}

?>

So, the output is :

postid: 1

posttitle: post title 1

date:2012-01-01

postid: 2

posttitle: post title 2

date:2012-01-01

postid: 3

posttitle: post title 1

date:2012-01-01

Once I add a foreach loop within the foreachloop, it shows me the metakey and meta_value of all the items. So It looks like this :

postid: 1

posttitle: post title 1

date:2012-01-01

metakey: Banner1URLforpost1

metavalue:[url removed, login to view]

metakey: Banner2URLforpost1

metavalue:[url removed, login to view]

metakey: Banner3URLforpost1

metavalue:[url removed, login to view]

metakey: Banner1URLforpost2

metavalue:[url removed, login to view]

metakey: Banner2URLforpost2

metavalue:[url removed, login to view]

metakey: Banner3URLforpost2

metavalue:[url removed, login to view]

metakey: Banner1URLforpost3

metavalue:[url removed, login to view]

metakey: Banner2URLforpost3

metavalue:[url removed, login to view]

metakey: Banner3URLforpost3

metavalue:[url removed, login to view]

postid: 2

posttitle: post title 2

date:2012-01-01

metakey: Banner1URLforpost1

metavalue:[url removed, login to view]

metakey: Banner2URLforpost1

metavalue:[url removed, login to view]

metakey: Banner3URLforpost1

metavalue:[url removed, login to view]

metakey: Banner1URLforpost2

metavalue:[url removed, login to view]

metakey: Banner2URLforpost2

metavalue:[url removed, login to view]

metakey: Banner3URLforpost2

metavalue:[url removed, login to view]

metakey: Banner1URLforpost3

metavalue:[url removed, login to view]

metakey: Banner2URLforpost3

metavalue:[url removed, login to view]

metakey: Banner3URLforpost3

metavalue:[url removed, login to view]

postid: 3

posttitle: post title 1

date:2012-01-01

metakey: Banner1URLforpost1

metavalue:[url removed, login to view]

metakey: Banner2URLforpost1

metavalue:[url removed, login to view]

metakey: Banner3URLforpost1

metavalue:[url removed, login to view]

metakey: Banner1URLforpost2

metavalue:[url removed, login to view]

metakey: Banner2URLforpost2

metavalue:[url removed, login to view]

metakey: Banner3URLforpost2

metavalue:[url removed, login to view]

metakey: Banner1URLforpost3

metavalue:[url removed, login to view]

metakey: Banner2URLforpost3

metavalue:[url removed, login to view]

metakey: Banner3URLforpost3

meta

Kemahiran: PHP, XML

Lihat lebih lanjut: php forums, xml post, xml help, output php, post error php, php output, date days php, post help, echo file php, php echo file, nodes, php days date, php sleep, xml data, xml error, add title php, xml post http, xml php output, http xml post, php meta title, php help needed, reading xml post php, php xml php, php xml multiple user writing time, php reading xml file

Tentang Majikan:
( 6 ulasan ) Cape Town, Namibia

ID Projek: #1525379

Dianugerahkan kepada:

Max01

let me do it sir serious bidder,see pmb

$50 USD dalam 0 hari
(135 Ulasan)
5.9

8 pekerja bebas membida secara purata $56 untuk pekerjaan ini

TheInnoVibes

Please check private message .

$150 USD dalam sehari
(208 Ulasan)
7.6
jigzyy

Hi, please check PM for details. Thanks

$55 USD dalam sehari
(88 Ulasan)
7.6
odmoriSe

Hi, check PM for solution

$30 USD dalam 0 hari
(39 Ulasan)
7.1
AlexLunix

Quick and easy solution, please see PM.

$30 USD dalam sehari
(29 Ulasan)
5.3
piaoxin

Hi, bennie501. I can do it. Please check PM. Thanks and regards.

$30 USD dalam 0 hari
(24 Ulasan)
5.3
Krishley

Professional programmer here. Can fix this for you! Please check your PMB. Thanks!

$35 USD dalam sehari
(1 Ulasan)
1.2
conscience

Hi, If the above sample is accurate, the problem is about the 'post' elements not being encapsulated and/or read correctly. I sent you a PM with further details. Regards, con

$70 USD dalam sehari
(0 Ulasan)
0.0