Parsing XML files from other sites?
Posted: 11 March 2008 12:02 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-06-2008

I didn’t get any reply from the general forum and so I move this question here and hope to have a better luck.

I am thinking to build a client’s website using EE.  The site is pretty standard stuff.  The only thing that is different is that some of the contents must be pulled from the headquarter site as an xml data source. (e.g. http;/example.com/abc.xml)

Is it possible to parse some XML files from another site and to display the contents on the template accordingly.  The magpie plugin won’t work since my files are not standard RSS/Atom files.  They have customized tags like “LeftContent”, “RightContent”...etc

I think someone mentions the use of Parse_XML class but do I really to get my feet wet to develop a module to handle this.

Thanks.

Profile
 
 
Posted: 11 March 2008 01:45 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15489
Joined  05-15-2004

Can it be done? Of course, parsing XML is pretty standard using PHP. Can EE do it out of the box, ie does it come with an inbuilt, drop-in XML parser? No, it does not.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 11 March 2008 02:12 PM   [ Ignore ]   [ # 2 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15869
Joined  06-03-2002

We do have an XML Parser class which can assist you, as the resulting data structure is a bit easier to traverse than what PHP provides on its own, but it will still take a bit of development on your part to process.

 Signature 
Profile
MSG
 
 
Posted: 11 March 2008 02:52 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-06-2008

That’s what I need to hear.  So I do need to take into account to develop a module in order to use EE to meet my client’s criteria.

And I agree xml parsing is pretty standard and that’s why I am surprised to see no such tool is available yet for EE.  And that’s why I ask to ensure I didn’t miss anything here.  Thanks anyway.

Profile
 
 
Posted: 11 March 2008 03:06 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15869
Joined  06-03-2002

Well the XML Parsing class is such a tool, but it’s broad-based since we cannot make assumptions about the structure and elements of your XML document.  The reason Magpie can do this so easily with a tag-based gateway (via the {exp:magpie} plugin tag) is because RSS/Atom XML docs have an expected structure and elements.  That’s not to say that a tag-based gateway to the XML Parsing class could not be made to handle a wide variety of document structures, but I would estimate that most of the users that could handle the complexity that that would require are probably versed enough in PHP to make use of our parsing class just as easily.  Don’t hesitate to post to the How To forum if you run into any speed-bumps with using the parser class, or the modules forums if you need help putting together a module to do the same.

 Signature 
Profile
MSG
 
 
Posted: 11 March 2008 03:35 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-06-2008

I am thinking on the line to parse the whole xml documents and store all structures and elements into an array and a developer can select the tags to display the content in whatever way they want.

Profile
 
 
Posted: 11 March 2008 03:39 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15869
Joined  06-03-2002

That is similar to the resulting data structure from our included XML parsing class, so you may still find it helpful.  You may have an existing preference for your PHP data structures though, so there’s certainly no harm in handling it exclusively without using our tools.

 Signature 
Profile
MSG
 
 
Posted: 19 May 2008 02:08 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15489
Joined  05-15-2004

You also might want to take a look at this plugin I recently discovered: http://www.brandnewbox.co.uk/docs/Home/Plugin:XMLGrab/

No personal experience with it yet, but might be worth a try.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 42
Total Topics: 82226 Total Anonymous Users: 21
Total Replies: 441924 Total Guests: 214
Total Posts: 524150    
Members ( View Memberlist )