SimpleXML processing _php Tutorials in PHP

Source: Internet
Author: User
Understanding and PHP (as the current mainstream development language) version 5 bundled Together Simplexml (standardization is getting closer) extension, it makes PHP (as the current mainstream development language) page can be PHP (as the current mainstream development language) friendly syntax to query, search, modify and Republish XM L (standardization is getting closer).

PHP (as the current mainstream development language) version 5 introduces Simplexml (standardization is getting closer), a new application programming interface (API) for reading and writing XML (standardization is getting closer). In Simplexml (normalization is getting closer), here's the expression:

$doc->rss->channel->item->title


Select an element from the document. It is easy to write this expression as long as you are familiar with the structure of the document. However, if it is not clear where the required elements appear (such as Docbook, HTML, and similar narrative documents), Simplexml (normalization is getting closer) can use XPath expressions to look for these elements.

Start using Simplexml (standardization getting closer)

Suppose you need a PHP (as the current mainstream development language) page to convert the RSS feed into HTML. RSS is a simple XML (standardized getting closer) format for publishing chained content. The root element of the document is RSS, which includes a channel element. The channel element contains metadata about the feed, such as the title, language, and URL. It also contains a variety of articles encapsulated in the item element. Each item has a LINK element, including a URL, and a title or description (usually both), containing plain text. Do not use namespaces. The content of RSS is of course more than that, but it's enough for this article to know. Listing 1 shows a typical example that contains two news items.

Listing 1. RSS Feed




<title>Mokka mit Schlag</title>
Http://www.elharo.com/blog
en

Penn Station:gone but not forgotten

The old Penn station in New York is torn down before I was born.
Looking at these pictures, which feels like a mistake. The current site is
Functional, but no more; Really just some office towers and underground
Corridors of no particular interest or beauty. The new Madison Square ...

Http://www.elharo.com/blog/new-york/2006/07/31/penn-station


Personal for Elliotte Harold
Some people use very obnoxious spam filters this require you
To type some random string of your subject such as e37t to get through.
Needless to say neither I nor the other people bother to communicate with
These paranoids. They is grossly overreacting to the spam problem.
Personally I wont ...

http://www.elharo.com/blog/tech/2006/07/28/personal-for-elliotte-harold/



Let's develop a PHP (as the current mainstream development language) page to format the RSS feed as HTML. Listing 2 shows the basic structure of this page.

Listing 2. Static structure of code for PHP (as the mainstream development language of today)




<?php (as the current mainstream development language)//The title will is read from the RSS?>

http://www.bkjia.com/PHPjc/508648.html www.bkjia.com true http://www.bkjia.com/PHPjc/508648.html techarticle Understanding and PHP (as the current mainstream development language) version 5 bundled Together Simplexml (standardization is getting closer) extension, it makes PHP (as the mainstream development language now) page can ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.