What do cdata tags do




















The data inside this will not be parsed. Otherwise, you will get an error as it will be parsed as regular XML and will be invalid. However this can become tricky as you need to watchout when to encode and decode those entities, therefore is recommendable to use CDATA instead.

CDATA sections may be added anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

The overall summary is while using CDATA to embed mark-up in XML document benefits us from having to encode the data, care should be taken with the effect of the client-server communication. You may also have a look at the following articles to learn more —. Submit Next Question. By signing up, you agree to our Terms of Use and Privacy Policy. Forgot Password?

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy.

Add powerful Web 2. Best Web Hosting. Top 10 Web Hosting. UK Reseller Hosting. Web Hosting. Custom Programming. Download XML editor. US Web Design Schools. Try saving the following as a. One big use-case: your xml includes a program, as data e. As paary mentioned, other common uses include when you're embedding URLs that contain ampersands. And as a explanation for why this example uses CData and not the appropriate pubData and dc:creator tags : this is for website display using a RSS widget for which we have no real formatting control.

This enables us to specify the height and position of the included image, format the author names and date correctly, and so forth, without the need for a new widget. It also means I can script this and not have to add them by hand. You can use this to escape some characters which otherwise will be treated as regular XML. The data inside this will not be parsed. Otherwise, you will get an error as it will be parsed as regular XML. It's used to contain data which could otherwise be seen as xml because it contains certain characters.

The Cdata is a data which you may want to pass to an xml parser and still not interpreted as an xml. Such open fields can have any data which does not strictly fall under basic data type or xml defined custom data types. Like -- Is this a correct tag for xml comment? Here Cdata comes to your rescue.

By declaring as Cdata you are telling the parser don't treat the data wrapped as an xml though it may look like one. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?



0コメント

  • 1000 / 1000