---
sourceDocument: 호주 API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/api-reference

 Release :

    - australia

ft:locale :

    - ko-KR

ft:publication_title :

    - 호주 API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# XMLUtilJS - 전역

# XMLUtilJS - 전역 {#ariaid-title1}

* 릴리스 버전: Australia
* 
* 업데이트 날짜 2026년 03월 12일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 8분

XMLUtilJS 스크립트 포함은 JavaScript를 스크립트와 함께 디스커버리 사용할 XML 유틸리티 메서드를 제공합니다.

이 스크립트 포함은 플러그인과 함께 제공됩니다.디스커버리 XML 유틸리티가 필요한 서버 측 디스커버리 스크립트에서 이 스크립트 포함을 사용합니다.

정적 변수 XMLUtilJS를 사용하여 이러한 메서드에 액세스합니다.

## XMLUtilJS - escapeForXMLText(문자열 텍스트) {#ariaid-title2}

지정된 문자열에 대한 이스케이프 텍스트를 제공합니다.
{#r_XUJ-escapeForXMLText_S__table_upj_wfs_pt__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 텍스트 | 문자열 | 서식을 지정할 텍스트입니다. |
[표 1. 매개변수]

{#r_XUJ-escapeForXMLText_S__table_upj_wfs_pt} {#r_XUJ-escapeForXMLText_S__table_vpj_wfs_pt__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 서식이 지정된 텍스트입니다. |
[표 2. 반환]

{#r_XUJ-escapeForXMLText_S__table_vpj_wfs_pt}  
다음 예제에서는 문서에 이스케이프된 XML 데이터를 나열하는 방법을 보여줍니다. stringToValue()도 참조하십시오.

    // Create an XML document to work with
    var doc = new XMLDocument2();

    // Add an element called catalog
    var catalog = doc.createElement('catalog');

    // Set current element to the one previously made to add more elements
    doc.setCurrentElement(catalog);

    // Add an element called catalog
    var bookAttribute = doc.createElement('book');

    // Add an attribute to the element created
    bookAttribute.setAttribute('id', 'bk101');

    // Create multiple elements with a defined value
    doc.createElementWithTextValue('author', 'Gambardella, Matthew');
    doc.createElementWithTextValue('title', 'XML Developer');
    doc.createElementWithTextValue('genre', 'Computer');
    doc.createElementWithTextValue('price', '44.95');

    // Pass the created XML document as a string to the XMLUtilJS API function
    var escapedXML = XMLUtilJS.escapeForXMLText(doc.toString());

    // Print the escapedXML. If an invalid XML is created, the original value will be returned
    gs.print(escapedXML);

출력:

    <?xml version="1.0" encoding="UTF-8"?><catalog><book id="bk101"/><author>Gambardella, Matthew</author><title>XML Developer</title><genre>Computer</genre><price>44.95</price></catalog>

## XMLUtilJS - stringToValue(문자열 문자열) {#ariaid-title3}

문자열을 XML 값으로 변환합니다.
{#r_XUJ-stringToValue_S__table_etz_b3s_pt__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 문자열 | 문자열 | 변환할 문자열입니다. |
[표 3. 매개변수]

{#r_XUJ-stringToValue_S__table_etz_b3s_pt} {#r_XUJ-stringToValue_S__table_ftz_b3s_pt__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 지정된 문자열이 XML로 변환되었습니다. |
[표 4. 반환]

{#r_XUJ-stringToValue_S__table_ftz_b3s_pt}  
다음 예제에서는 이스케이프된 XML 문자열을 태그가 지정된 XML 출력으로 변환하는 방법을 보여 줍니다. escapeForXMLText()도 참조하십시오.

    //Example of an escaped XML string, previously generated by XMLUtilJS.escapeForXMLText()
    var escapedXML = '<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer\'s Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>';

    //Pass in escaped XML text and store output in a variable
    var output = XMLUtilJS.stringToValue(escapedXML);

    // If the input value is a string value of NULL, the output will be null, otherwise an unescaped XML string value.
    gs.print(output);

출력:

    <catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>

## XMLUtilJS - unescapeForXMLText(문자열 텍스트) {#ariaid-title4}

지정된 문자열에 대해 이스케이프되지 않은 XML을 제공합니다.
{#r_XUJ-unescapeForXMLText_S__table_in5_pgs_pt__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 텍스트 | 문자열 | 정리할 XML 텍스트입니다. |
[표 5. 매개변수]

{#r_XUJ-unescapeForXMLText_S__table_in5_pgs_pt} {#r_XUJ-unescapeForXMLText_S__table_jn5_pgs_pt__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 정리된 XML 문자열입니다. |
[표 6. 반환]

{#r_XUJ-unescapeForXMLText_S__table_jn5_pgs_pt}  
다음 예제에서는 이스케이프된 XML 문자열을 태그가 지정된 XML 출력으로 변환하는 방법을 보여줍니다. escapeForXMLText()도 참조하십시오.

    //Example of an escaped XML string, previously generated by XMLUtilJS.escapeForXMLText()
    var escapedXML = '<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer\'s Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>';

    //Pass in escaped XML text and store output in a variable
    var output = XMLUtilJS.unescapeForXMLText(escapedXML);


    //Print the escapedXML. If the XML is invalid, the original value will be returned
    gs.print(output);

출력:

    <catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>

## XMLUtilJS - valueToString(String XMLvalue) {#ariaid-title5}

XML 값을 문자열로 변환합니다.
{#r_XUJ-valueToString_S__table_ix2_4hs_pt__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| XML값 | 문자열 | 변환할 XML |
[표 7. 매개변수]

{#r_XUJ-valueToString_S__table_ix2_4hs_pt} {#r_XUJ-valueToString_S__table_jx2_4hs_pt__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 문자열로 변환된 XML 값입니다. |
[표 8. 반환]

{#r_XUJ-valueToString_S__table_jx2_4hs_pt}  
다음 예제에서는 XML 문서를 문자열로 변환하는 방법을 보여 줍니다.

    //Create an XML document to work with
    var doc = new XMLDocument2();

    //Add an element called catalog
    var catalog = doc.createElement("catalog");

    //Set our current element to the one previously made to add further elements
    doc.setCurrentElement(catalog);

    //Add an element called catalog
    var bookAttribute = doc.createElement("book");

    //Add an attribute to the element created
    bookAttribute.setAttribute("id" , "bk101");

    //create multiple elements with a defined value
    doc.createElementWithTextValue("author" , "Gambardella, Matthew");
    doc.createElementWithTextValue("title" , "XML Developer");
    doc.createElementWithTextValue("genre" , "Computer");
    doc.createElementWithTextValue("price" , "44.95");

    //Pass the created XML document as a string to the XMLUtilJS API function.
    var escapedXML = XMLUtilJS.valueToString(doc.toString());

    // Print the results
    // Returns NULL if XML is invalid
    gs.print(escapedXML);

출력:

    <?xml version="1.0" encoding="UTF-8"?><catalog><book id="bk101"/><author>Gambardella, Matthew</author><title>XML Developer</title><genre>Computer</genre><price>44.95</price></catalog>


