XML & URL Encoding

A URL, or Uniform Resource Locator, specifies the address of a resource on the Internet. Because URLs are limited to a subset of ASCII characters, it is sometimes necessary to replace "unsafe" characters with an encoded representation. In XML these encodings can be described using entities.

  1. Entities in XML

    • Entities in XML begin with the ampersand (&) and pound sign (#) followed by the character encoding. The entity is terminated with a semicolon (;). For example, the encoding "&#37;" could be used to represent the percent sign. If the character encoding is preceded with an x, the encoding is assumed to be a hex encoding. For example, "&#x3C;" represents the less than (<) sign.

    Predefined Entities

    • XML also defines several commonly used characters that are reserved in HTML and XML. For example, "&amp;" represents the ampersand character. The predefined entities in XML are amp, lt, gt, apos and quot.

    Example

    • A URL to get an RSS feed might look like the following:

      http://myurl.com/rss?get="myfeed('c:\feed.xml')"

      Encoding this URL yields the following results:

      http://myurl.com/rss?get=%22myfeed('c:%5Cfeed.xml')%22

      The XML element for this encoding would be as follows:

      <myURL>http://myurl.com/rss?get=%22myfeed(&apos;c:%5Cfeed.xml&apos;)%22</myURL>

Related Searches:

References

Resources

Comments

You May Also Like

  • Base64 Encoding in XML

    It is possible to store string data within an XML element. However, the preferred method for large strings is to pass your...

  • XML Encoding & ASP

    Because various computers use different numerical values to represent character sets, XML provides a means for defining which character set is being...

  • How Do I Send a British Pound Symbol Through SMTP?

    SMTP stands for Simple Mail Transfer Protocol and is the method by which a server accepts email you send and relays it...

  • How to Create RSS Video

    Adding a RSS feed to your website or blog allows users to be kept continually updated and is a great way to...

  • How to Encode an Apostrophe in a URL

    It is not possible to use an apostrophe within a URL you assign to a page or post on your website, even...

  • How to Specify Encoding for XML

    Developers who create programs to read and process XML files face an odd paradox when it comes to determining each file's encoding,...

  • How to Submit a Video Podcast Into iTunes 4.9

    After you've created your video podcast, and you are ready to display it to the world, you have to think about placement....

  • XML to ASCII Conversion

    A chief benefit of XML is that it allows you to tag data and output (or transform) element content into any one...

Related Ads

Featured