Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-29-2014, 05:17 AM   #1
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
programmers - help with xml feed

So I am trying to read in an xml feed with php, however the feed has thrown me a bit of a curve ball.

It starts off as a normal xml feed, however mid way it changes and this is what is throwing me. How do I handle a feed that does the following : ?

PHP Code:
<element>
 <
item>
  <
itemid>
  </
itemid>
 </
item>
 <
item>
  <
itemid>
  </
itemid>
 </
item>
 <
item>
  <
itemid>
  </
itemid>
 </
item>
 <
item>
  <
itemid>
  </
itemid>
 </
item>

<!---- 
Then it changes ---->
<
newelement>
 <
newsubelement>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
 </
newsubelement>
 <
newsubelement>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
  <
item>
  <
itemid>
  </
itemid>
  </
item>
 </
newsubelement>
</
element
Any help would be much appreciated!

cheers
__________________
TripleXPrint on Megan Fox
"I would STILL suck her pussy until her face caved in. And then blow her up and do it again!"
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 05:38 AM   #2
superman1
Registered User
 
Industry Role:
Join Date: Dec 2013
Posts: 49
the right way: request to from the source of xml to send valid xml :-)

alternative way: sanitize the data, fix the xml or extract data with regexp -> but both is not the right way....
superman1 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 05:47 AM   #3
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Quote:
Originally Posted by superman1 View Post
the right way: request to from the source of xml to send valid xml :-)

alternative way: sanitize the data, fix the xml or extract data with regexp -> but both is not the right way....
haha well not possible to get them to change it at all unfortunately.

Was hoping for a way to loop through without having to sanitize the data as you mentioned.

Thanks for the reply.
__________________
TripleXPrint on Megan Fox
"I would STILL suck her pussy until her face caved in. And then blow her up and do it again!"
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 05:53 AM   #4
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,108
I feed most XML through DreamWeaver and add it as a recordset - It is pretty good at sorting out strange looking XML like that...
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 05:56 AM   #5
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Quote:
Originally Posted by EddyTheDog View Post
I feed most XML through DreamWeaver and add it as a recordset - It is pretty good at sorting out strange looking XML like that...
The problem is, I want to set it up with a cronjob so my code can read the xml - add updates if there are any otherwise leave everything until the next time the cronjob runs

Right now, I can read in bits of the xml feed, but not all of it because they have made it in such a shit of a way.
__________________
TripleXPrint on Megan Fox
"I would STILL suck her pussy until her face caved in. And then blow her up and do it again!"
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 06:50 AM   #6
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Bump?............
__________________
TripleXPrint on Megan Fox
"I would STILL suck her pussy until her face caved in. And then blow her up and do it again!"
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 06:59 AM   #7
superman1
Registered User
 
Industry Role:
Join Date: Dec 2013
Posts: 49
I'm not sure if I catch the realy problem, does PHP accept the XML you get or you get there a error? If Simple XML or whatever engine you use take it, you could use xpath to get what you need.
superman1 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 07:05 AM   #8
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
can you give me a live url to the xml feed so i can give you the code?

chris @ lod.com
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 11:04 AM   #9
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
XML Parsing Error: mismatched tag. Expected: </newelement>.
Location: ****
Line Number 53, Column 3:</element>
--^

Bad posting paste job?

At any rate try a data dump and look at the array.
You may need to use Xpath

Last edited by Barry-xlovecam; 04-29-2014 at 11:07 AM..
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 11:18 AM   #10
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
Code:
$VAR1 = {
          'item' => [
                    {
                      'itemid' => {}
                    },
                    {
                      'itemid' => {}
                    },
                    {
                      'itemid' => {}
                    },
                    {
                      'itemid' => {}
                    }
                  ],
          'newelement' => {
                          'newsubelement' => [
                                             {
                                               'item' => [
                                                         {
                                                           'itemid' => {}
                                                         },
                                                         {
                                                           'itemid' => {}
                                                         },
                                                         {
                                                           'itemid' => {}
                                                         }
                                                       ]
                                             },
                                             {
                                               'item' => [
                                                         {
                                                           'itemid' => {}
                                                         },
                                                         {
                                                           'itemid' => {}
                                                         },
                                                         {
                                                           'itemid' => {}
                                                         },
                                                         {
                                                           'itemid' => {}
                                                         }
                                                       ]
                                             }
                                           ]
                        }
        };
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2014, 07:42 PM   #11
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,683
create 1 php to sanitize data and or format the wront xml to correct xml,, then use your regular xml code to parse the xml.

or you can just create one file of it.
freecartoonporn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2014, 03:57 AM   #12
Milan_Quantox
Confirmed User
 
Industry Role:
Join Date: Aug 2012
Posts: 1,768
You have elements and subelements. Please send me whole code you used to parse this, and one of my devs will fix it for you [email protected]
__________________
Milan_Quantox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.