Converts strings to be xml safe
495540
function( string ) {
		return ( string || '' ).replace( ramp, "&amp;" )
			.replace( rquote, "&quot;" )
			.replace( rsquote, "&#039;" )
			.replace( rlt, "&lt;" )
			.replace( rgt, "&gt;" );
	}
746291
public static String xmlAttribEncode(final String attrValue) {
    final StringBuffer buf = new StringBuffer(attrValue);
    int quotePos;

    for (quotePos = -1; (quotePos = buf.indexOf("\"", quotePos + 1)) >= 0;) {
      buf.deleteCharAt(quotePos);
      buf.insert(quotePos, "&quot;");
      quotePos += 5;
    }

    for (quotePos = -1; (quotePos = buf.indexOf("<", quotePos + 1)) >= 0;) {
      buf.deleteCharAt(quotePos);
      buf.insert(quotePos, "&lt;");
      quotePos += 3;
    }

    for (quotePos = -1; (quotePos = buf.indexOf(">", quotePos + 1)) >= 0;) {
      buf.deleteCharAt(quotePos);
      buf.insert(quotePos, "&gt;");
      quotePos += 3;
    }

    return buf.toString();
  }
528661
def encodeXML( text, doNPChars = false )
      encodingStrings { |key,value| text.gsub!( key, value ) if text }
      text.gsub!( /([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()# ])/ ) { |c| escapeXML( $1 ) } if text and doNPChars
      text
   end
1041982
private String prepareXmlForParsing(String xml) throws TheDavidBoxClientException{
		//Escape all & symbols in the response so it can parse it later
		xml = xml.replaceAll("&", "&amp;");
		
		String xmlReady;
		try {
			//It repairs the encoding to allow all utf-8 symbols
			xmlReady = new String(xml.getBytes(), CHARSET_ENCODING);
		} catch (UnsupportedEncodingException e) {
			throw new TheDavidBoxClientException(e);
		}
		return xmlReady;
	}
66705
function(str) {
		var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g;

		return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) {
			return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr;
		}) : str;
	}
302382
function cleanXML(xmlStr) {
    
    xmlStr = xmlStr.replace( /<!--[\s\S]*?-->/g, '' ); //remove commented lines
    xmlStr = xmlStr.replace(/\n|\t|\r/g, ''); //replace special characters
    xmlStr = xmlStr.replace(/ {1,}<|\t{1,}</g, '<'); //replace leading spaces and tabs
    xmlStr = xmlStr.replace(/> {1,}|>\t{1,}/g, '>'); //replace trailing spaces and tabs
    xmlStr = xmlStr.replace(/<\?[^>]*\?>/g, ''); //delete docType tags

    xmlStr = replaceSelfClosingTags(xmlStr); //replace self closing tags
    xmlStr = replaceAloneValues(xmlStr); //replace the alone tags values
    xmlStr = replaceAttributes(xmlStr); //replace attributes

    return xmlStr;
}
1317840
def _safe_attr(attr, camel_killer=False, replacement_char='x'):
    """"""
    allowed = string.ascii_letters + string.digits + '_'

    attr = _safe_key(attr)

    if camel_killer:
        attr = _camel_killer(attr)

    attr = attr.replace(' ', '_')

    out = ''
    for character in attr:
        out += character if character in allowed else "_"
    out = out.strip("_")

    try:
        int(out[0])
    except (ValueError, IndexError):
        pass
    else:
        out = '{0}{1}'.format(replacement_char, out)

    if out in kwlist:
        out = '{0}{1}'.format(replacement_char, out)

    return re.sub('_+', '_', out)
1131343
def safe_str(value):
    
    if sys.version_info < (3,0) and isinstance(value, unicode):
        return value.encode('utf-8')
    else:
        return str(value)
690947
private Source sanitizeXml(@Nullable String xml) {
    if (xml != null && !sensitiveXPathStrings.isEmpty()) {
      try {
        DocumentBuilder documentBuilder = documentBuilderSupplier.get();
        XPath xpath = xpathSupplier.get();
        if (documentBuilder != null && xpath != null) {
          Document doc = documentBuilder.parse(new InputSource(new StringReader(xml)));
          for (String xpathString : sensitiveXPathStrings) {
            XPathExpression expr = xpath.compile(xpathString);
            Node node = (Node) expr.evaluate(doc, XPathConstants.NODE);
            if (node != null && node.getTextContent() != null) {
              node.setTextContent("REDACTED");
            }
          }
          return new DOMSource(doc);
        }
      } catch (SAXException e) {
        libLogger.warn("Unable to parse XML: {}", e);
      } catch (IOException e) {
        libLogger.warn("Unable to parse XML: {}", e);
      } catch (XPathExpressionException e) {
        libLogger.warn("Unable to parse XML: {}", e);
      }
    }
    return null;
  }
1126458
def enc(x, codec='ascii'):
    """"""
    x = x.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')
    return x.encode(codec, 'xmlcharrefreplace')
651168
def to_xml_string(idx, str = "")
      Axlsx::validate_unsigned_int(idx)
      if !v.to_s.empty?
        str << ('<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>')
      end
    end
1313122
@Override
  public final String unescapeXml(final String pSource) throws Exception {
    StringBuffer sb = new StringBuffer();
    StringBuffer sbEsc = new StringBuffer();
    boolean isStartEsc = false;
    for (int i = 0; i < pSource.length(); i++) {
      char ch = pSource.charAt(i);
      if (!isStartEsc && ch == '&') {
        isStartEsc = true;
        sbEsc.append(ch);
        continue;
      } else if (isStartEsc) {
        sbEsc.append(ch);
        if (ch == ';') {
          sb.append(xmlUnescape(sbEsc.toString()));
          sbEsc.delete(0, sbEsc.length());
          isStartEsc = false;
        }
      } else {
        sb.append(ch);
      }
    }
    return sb.toString();
  }
1137365
public static function convertXMLValueToString(string $str) : string
    {
        $str = str_replace("&amp;", "&", $str);
        $str = str_replace("&lt;", "<", $str);
        $str = str_replace("&gt;", ">", $str);
        $str = str_replace("&apos;", "'", $str);
        $str = str_replace("&quot;", "\"", $str);

        return $str;
    }
917280
def to_xml_string(str='')
      return if empty?
      str << '<hyperlinks>'
      each { |hyperlink| hyperlink.to_xml_string(str) }
      str << '</hyperlinks>'
    end
585048
def _pretty_xml(xml_string):
    

    result_dom = minidom.parseString(xml_string)
    pretty_result = result_dom.toprettyxml(indent='  ')

    # remove extra empty lines
    return re.sub(r'>( *[\r\n]+)+( *)<', r'>\n\2<', pretty_result)
594627
public static String escapeForXML(String inString) {
    if (inString == null)
      return null;
    String outString = inString;
    outString = replace(outString, "&", "&amp;");
    outString = replace(outString, "<", "&lt;");
    outString = replace(outString, ">", "&gt;");
    outString = replace(outString, "\"", "&quot;");
    outString = replace(outString, "'", "&apos;");
    // We'll escape all chars not in this set (Safe)
    String validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 &#;-_=+:,.?/";
    for (int i = 0; i < outString.length(); i++) {
      char c = outString.charAt(i);
      if (validChars.indexOf(c) == -1) {
        // Escape the character
        outString = replace(outString, "" + c, "&#" + ((int) c) + ";");
      }
    }
    return outString;
  }
526359
def to_xml_string(str = '')
      valid_attributes = get_valid_attributes

      str << '<dataValidation '
      str << instance_values.map do |key, value| 
        '' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym)) 
      end.join(' ')
      str << '>'
      str << ('<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1)
      str << ('<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2)
      str << '</dataValidation>'
    end