/    Sign up×
Community /Pin to ProfileBookmark

Parsing XML with PHP

I don’t know why I’m having so much trouble with this, but I need to use a single XML file as a reference for parsing data. I am using XML instead of MySQL here for server limitation reasons.

Say this is my basic XML structure:

[CODE]<journal id=”11″>
<name>Journal 1 Title</name>
<url>http://www.journal1.com</url>
</journal>
<journal id=”127″>
<name>Journal 2 Title</name>
<url>http://www.journal2.com</url>
<coverImage>journal2coverimage.jpg</coverImage>
</journal>[/CODE]

On a website, I would like to use this data following this model:

[code=html]<a href=”<?php print getURL(11); ?>”><?php print getName(11); ?><img src=”<?php print getCoverImage(11); ?>” alt=”<?php print getName(11); ?>”></a>[/code]

This code would ideally pull form the XML document the title, cover image, and URL link for Journal 1.

I need functions that can parse my XML file (journals.xml) and return the appropriate values with the three functions in the HTML code above. I am so lost. Any advice?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @wally121 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...