Fabric.js escapeXml() Method
The escapeXml() method is used to escape the characters of the XML markup language present in the specified string.
Syntax:
escapeXml(string)
Parameters: This method accepts a parameter as mentioned above and described below:
- string: This parameter holds the string to escape.
Return Value: This method returns the escaped version of the specified string.
Example 1:
Javascript
<!DOCTYPE html>
<html>
<head>
<script src=
</script>
<script type= "text/javascript" src=
</script>
<script type= "text/javascript" src=
</script>
</head>
<body>
<script type= "text/javascript" >
console.log(fabric.util.string.escapeXml( "GeeksforGeeks" ));
console.log(fabric.util.string.escapeXml( "Geeks<abc>for</abc>Geeks" ));
console.log( "Geeks<abc>for</abc>Geeks" );
</script>
</body>
</html>
|
Output:
GeeksforGeeks
Geeks<abc>for</abc>Geeks
GeeksforGeeks
Example 2:
Javascript
<!DOCTYPE html>
<html>
<head>
<script src=
</script>
<script type= "text/javascript" src=
</script>
<script type= "text/javascript" src=
</script>
</head>
<body>
<script type= "text/javascript" >
console.log( "Using escapeXml() Function:" );
var value= "GFG <a> is a CS </a> portal." ;
console.log(fabric.util.string.escapeXml(value));
console.log( "Without using escapeXml() Function:" );
var value= "GFG <a> is a CS </a> portal." ;
console.log(value);
</script>
</body>
</html>
|
Output:
Using escapeXml() Function:
GFG <a> is a CS </a> portal.
Without using escapeXml() Function:
GFG is a CS portal.
Last Updated :
05 Jan, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...