File: double-escaping-example.pl

package info (click to toggle)
libxml-writer-perl 0.900-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 2,609; makefile: 2
file content (17 lines) | stat: -rwxr-xr-x 394 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl -w

# Demonstrate that ampersands are double-escaped

# Even if your text looks like already-escaped XML, it will be escaped
#  again to make sure that the same text arrives at the other end.

use strict;

use XML::Writer;

my $w = XML::Writer->new();

$w->startTag('doc');
$w->characters('In HTML and XML, an ampersand must be escaped as &');
$w->endTag('doc');
$w->end();