2012-08-28 00:03
浏览 129


I'm learning about PHP and web coding.
Specifically, the PHP book I'm using that covers PHP 5.3 (by Matt Doyle and published by Wrox), says:

XML ... lets you create text documents that can hold data in a structured way...
XML isn't really a language but rather a sepcification for creating your own markup languages...

Wikipedia says of XML:

As of 2009, hundreds of XML-based languages have been developed,[8] including RSS, Atom, SOAP, and XHTML. XML-based formats have become the default for many office-productivity tools, including Microsoft Office (Office Open XML), OpenOffice.org and LibreOffice (OpenDocument), and Apple's iWork.[9] XML has also been employed as the base language for communication protocols, such as XMPP.

It sounds like XML is more like a protocol, a standard for allowing compuers to communicate and share information.

So XML is like a grammar I can use to create a markup language, but the language I create only formats data?

I want help defining the relationship between PHP and XML. When during the processesing of PHP and HTML does XML get parsed?

图片转代码服务由CSDN问答提供 功能建议

具体来说,我正在使用的PHP书籍包括PHP 5.3(由Matt Doyle出版并由Wrox出版),说:

XML ...让 您可以创建可以以结构化方式保存数据的文本文档...


截至2009年,已经开发了数百种基于XML的语言,[8]包括RSS,Atom, SOAP和XHTML。 基于XML的格式已成为许多办公生产力工具的默认格式,包括Microsoft Office(Office Open XML),OpenOffice.org和LibreOffice(OpenDocument)以及Apple的iWork。[9] XML也被用作通信协议的基本语言,例如XMPP。

听起来XML更像是一个协议,一个允许计算机的标准 沟通和共享信息。


我想要帮助定义PHP和XML之间的关系。 当在PHP和HTML的处理过程中,XML是否被解析?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • donglan6777 2012-08-28 00:05

    XML is not a grammar (that's another thing entirely). XML (as the name suggests) is a markup language that essentially defines a set of rules that describe something. The "something" could be a protocol, the structure of a document, or any kind of data. XML is designed to be machine readable and human readable (although in my opinion, with bias towards the former ;)).

    XML documents use something called a schema which describes the structure of the XML itself, and so you can validate an XML document against a schema to make sure that it is well-formed.

    There is no relation between PHP and XML. XML is something that PHP can consume and produce. There is nowhere during processing that PHP consumes or produces XML unless you explicitly tell PHP to do so.

    XML is sometimes used as sort a of "glue" that allows dissimilar or disparate systems to communicate with each other, but even that is just one of its functions. For example, PHP can consume XML produced by a program written in another language entirely, or XML produced by some website. PHP can also produce XML which can then be consumed by a program written in another language, or by some other source. As you found from the Wikipedia article, SOAP uses XML and this allows clients written in different languages to consume data exposed by a SOAP service.

    打赏 评论
  • douzou0073 2012-08-28 00:09

    XML gives a starting point for a lot of technologies, particularly web technologies.

    While PHP can be used for other things, its origins are in the web and it is still most heavily used there. As such, it would be sorely lacking if it couldn't deal with such a core web technology as XML. Likewise, it has support for other key web technologies like URIs, and those heavily used with the web like streams and database connections.

    打赏 评论
  • donh61500 2012-08-28 00:10

    XML is only a data format specification. It was once very hipped but has somewhat faded in favor of JSON - it is still VERY popular because there are many protocols using it as the data interchange format.

    PHP is generic enough (as a programming language) to generate XML as well as any other data format.

    Since XML is such an important data format, every respectable programming language is expected to easily consume XML as well, and PHP is no exception.

    打赏 评论

相关推荐 更多相似问题