/    Sign up×
Community /Pin to ProfileBookmark

How To Convert This From OOP To Procedural Style ?

Hi,

I am still at procedural style programming. And so, oop code sample codes really do bug & confuse me.
I do not understand these ‘–>’.
I am used to ().
I found this oop style php code that parses xml files for links.
Any chance someone can show me how to convert this to procedural style ?
Oh yes. Test the code. It really woks fine!
But if anyone finds a simple procedural style php code then do let me know.

Thanks

[code]
// sitemap url or sitemap file
$sitemap = ‘https://bytenota.com/sitemap.xml’;

// get sitemap content
$content = file_get_contents($sitemap);

// parse the sitemap content to object
$xml = simplexml_load_string($content);

// retrieve properties from the sitemap object
foreach ($xml->url as $urlElement) {
// get properties
$url = $urlElement->loc;
$lastmod = $urlElement->lastmod;
$changefreq = $urlElement->changefreq;
$priority = $urlElement->priority;

// print out the properties
echo ‘url: ‘. $url . ‘<br>’;
echo ‘lastmod: ‘. $lastmod . ‘<br>’;
echo ‘changefreq: ‘. $changefreq . ‘<br>’;
echo ‘priority: ‘. $priority . ‘<br>’;

echo ‘<br>—<br>’;
}
[/code]

https://bytenota.com/parsing-an-xml-sitemap-in-php/

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@novice2022authorOct 12.2022 — Programmers,

The above code is echoing:

**url: https://www.rocktherankings.com/footer-links-seo/

lastmod: 2022-03-14T13:19:37+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/seo-quick-wins/

lastmod: 2022-05-20T23:30:31+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/what-is-cro/

lastmod: 2022-05-20T23:35:26+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/how-to-get-higher-google-rankings/

lastmod: 2022-05-21T00:20:22+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/how-long-does-seo-take/

lastmod: 2022-05-21T22:04:58+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/wordpress-301-redirect/

lastmod: 2022-05-21T22:07:33+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/sitemap-examples/

lastmod: 2022-05-21T22:48:14+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/travel-marketing-tips/

lastmod: 2022-05-21T23:10:35+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/travel-seo-tips/

lastmod: 2022-05-21T23:25:16+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/on-page-seo-checklist/

lastmod: 2022-05-25T10:16:21+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/b2b-seo/

lastmod: 2022-06-22T18:12:37+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/seo-campaign/

lastmod: 2022-06-22T18:14:54+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/local-keyword-research/

lastmod: 2022-07-02T17:50:46+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/rank-higher-google-maps/

lastmod: 2022-07-02T17:50:50+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/local-seo-ranking-factors/

lastmod: 2022-07-02T17:50:54+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/local-seo-audit/

lastmod: 2022-07-02T17:51:00+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/local-lead-generation/

lastmod: 2022-07-02T17:51:04+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/local-search-marketing/

lastmod: 2022-07-02T17:51:09+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/how-to-add-my-business-to-google-maps/

lastmod: 2022-07-02T17:51:20+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/seo-reputation-management/

lastmod: 2022-07-02T17:51:21+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/how-to-delete-a-google-review/

lastmod: 2022-07-02T17:51:25+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/google-my-business-categories/

lastmod: 2022-07-02T17:51:41+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/content-brief/

lastmod: 2022-07-03T07:52:14+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-seo-mistakes/

lastmod: 2022-07-18T14:16:11+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/ppc-for-saas/

lastmod: 2022-07-25T13:07:07+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/website-audit-checklist/

lastmod: 2022-07-26T17:39:20+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-keyword-research/

lastmod: 2022-07-26T17:41:34+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-seo-tools/

lastmod: 2022-07-26T17:42:58+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/b2b-saas-content-strategy/

lastmod: 2022-08-11T10:23:13+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-internal-linking/

lastmod: 2022-09-25T17:16:31+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/get-more-google-reviews/

lastmod: 2022-09-27T12:33:01+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/b2b-saas-copywriting/

lastmod: 2022-10-07T14:46:00+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-link-building/

lastmod: 2022-10-07T15:06:39+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/technical-seo-saas/

lastmod: 2022-10-07T15:07:35+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/saas-seo/

lastmod: 2022-10-10T10:23:05+00:00

changefreq:

priority:


---
url: https://www.rocktherankings.com/competitor-comparison-landing-pages/

lastmod: 2022-10-10T10:23:30+00:00

changefreq:

priority:

---**
Copy linkTweet thisAlerts:
@NogDogOct 12.2022 — If you are going to use that 3rd-party software, then you're going to have to use OOP syntax, since it is OOP code. There is no way to re-write you code to avoid OOP syntax unless you completely re-write that software.
Copy linkTweet thisAlerts:
@novice2022authorOct 12.2022 — @NogDog#1647816

Ok. Let me give it a shot.

But fiirst got to learn from you how to convert the syntax.

So, let's try with a smaller script. Shall we ?

Any chance you can convert this to procedural ?
<i>
</i> include_once('simplehtmldom_1_9_1/simple_html_dom.php');
//---
$url = "https://www.rocktherankings.com/post-sitemap.xml";
$html = new simple_html_dom();
$html-&gt;load_file($url);
//--
foreach($html-&gt;find("loc") as $link)
{
echo $link-&gt;innertext."&lt;br&gt;";
}

From your converted code, I will see the difference or detect the differences between the two styles and learn the syntax. Then, I will try attempting to convert the first code mentioned on my previous post.

Good idea ?

That way, once I have learnt the syntax then I won't have to bug you people anymore and can do the conversions myself whenever I find code samples online.
×

Success!

Help @novice2022 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.18,
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,
)...