コードを見ると、escape_valueメソッドが文字列を受け取り、次の置換でその文字列を返すように見えます。
>に>
<に<
&に&
"に"
オブジェクトの構造を操作することさえありません。直接呼び出す場合は、次のようにします。
my $string = '"Remove quotes" & <entities> quotes';
my $encoded_string = $self->escape_value( "$string" );
say $encoded_string; #"Remove quotes" & and <entities> quotes
一体、なぜオブジェクト指向にこだわる必要があるのでしょうか?
my $string = '"Remove quotes" & <entities> quotes';
my $encoded_string = XML::Simple::escape_value( "$string" );
say $encoded_string; #"Remove quotes" & and <entities> quote
XMLOutオプションNoEscapeが設定されていないか、 に設定されている場合は常に、このサブルーチンが自動的に呼び出されるように見えます0。
コードの 636 行目で、XMLOutメソッドはメソッドを呼び出していvalue_to_xmlます。これは、XMLOut に渡されたデータ構造を受け取り、XML テキストを作成します。次に、メソッドは 1431 行でメソッドvalue_to_xmlを呼び出します。escape_string