@azure/core-xml
Advanced tools
Comparing version
import type { XmlOptions } from "./xml.common.js"; | ||
/** | ||
* Converts given XML string into JSON | ||
* @param str - String containing the XML content to be parsed into JSON | ||
* @param opts - Options that govern the parsing of given xml string | ||
* `includeRoot` indicates whether the root element is to be included or not in the output | ||
*/ | ||
export declare function parseXML(str: string, opts?: XmlOptions): Promise<any>; | ||
export declare function stringifyXML(content: unknown, opts?: XmlOptions): string; | ||
/** | ||
* Converts given JSON object to XML string | ||
* @param obj - JSON object to be converted into XML string | ||
* @param opts - Options that govern the XML building of given JSON object | ||
* `rootName` indicates the name of the root element in the resulting XML | ||
*/ | ||
export declare function stringifyXML(obj: unknown, opts?: XmlOptions): string; | ||
//# sourceMappingURL=xml-browser.d.mts.map |
@@ -26,2 +26,8 @@ // Copyright (c) Microsoft Corporation. | ||
const parser = new DOMParser(); | ||
/** | ||
* Converts given XML string into JSON | ||
* @param str - String containing the XML content to be parsed into JSON | ||
* @param opts - Options that govern the parsing of given xml string | ||
* `includeRoot` indicates whether the root element is to be included or not in the output | ||
*/ | ||
export function parseXML(str, opts = {}) { | ||
@@ -146,3 +152,9 @@ var _a, _b, _c, _d, _e, _f; | ||
const serializer = new XMLSerializer(); | ||
export function stringifyXML(content, opts = {}) { | ||
/** | ||
* Converts given JSON object to XML string | ||
* @param obj - JSON object to be converted into XML string | ||
* @param opts - Options that govern the XML building of given JSON object | ||
* `rootName` indicates the name of the root element in the resulting XML | ||
*/ | ||
export function stringifyXML(obj, opts = {}) { | ||
var _a, _b, _c, _d, _e; | ||
@@ -156,3 +168,3 @@ const updatedOptions = { | ||
}; | ||
const dom = buildNode(content, updatedOptions.rootName, updatedOptions)[0]; | ||
const dom = buildNode(obj, updatedOptions.rootName, updatedOptions)[0]; | ||
return ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + | ||
@@ -159,0 +171,0 @@ serializer.serializeToString(dom).replace(/ xmlns=""/g, "")); |
{ | ||
"name": "@azure/core-xml", | ||
"version": "1.5.0", | ||
"version": "1.5.1-alpha.20250718.3", | ||
"description": "Core library for interacting with XML payloads", | ||
@@ -76,4 +76,4 @@ "sdk-type": "client", | ||
"devDependencies": { | ||
"@azure/dev-tool": "^1.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0", | ||
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb", | ||
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb", | ||
"@types/node": "^20.0.0", | ||
@@ -80,0 +80,0 @@ "@types/trusted-types": "^2.0.0", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
74294
2.34%702
3.54%1
Infinity%183
-0.54%