Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

CHAPTER 2 XML STRUCTURE Listing 2-11. Example

Filed under: PHP and XML — webmaster @ 21:11

CHAPTER 2 XML STRUCTURE Listing 2-11. Example Using CDATA Section this & that ]]> Clearly, the document in Listing 2-11 is much easier to read than the one in Listing 2-10. If editing a document by hand, it is also easier to write because you don t need to be concerned with figuring out what the correct entities to use are. Because of the flexibility of CDATA sections, you may have heard or read somewhere that CDATA is great to use for binary data. In its native form, this is not true. You have no guarantee that the binary data will not contain the characters ]]>. For this reason, binary data that must be encoded should use a format such as Base64. Now, if Base64 is used for encoding, a CDATA section is not even necessary, and it could be embedded directly as an element s content. This is because Base64 does not use any of the characters that would be deemed illegal for element content. Comments You can use comments to add notes to a document. This is comparable to a developer adding comments to source code. They do not affect the document but can be used to add some notes or information for someone reading it. For this reason, parsers are not required to parse comments, although most will allow access to the content. This is what a comment looks like: Comments consist of the initial . Be aware of the following stipulations when using comments: The content for a comment must not contain –. A comment may not end with -. Other than those conditions, comments can contain any other characters. Comments may also occur anywhere after the XML declaration as long as they are not contained within markup. Listing 2-12 shows some valid comments, and Listing 2-13 shows some invalid ones. Listing 2-12. Valid Comments

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Cheap Web Hosting