How to use xmlbuilder - 10 common examples

To help you get started, we’ve selected a few xmlbuilder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / jsii / packages / jsii-pacmak / lib / targets / dotnet.ts View on Github external
// If dotnet-runtime is checked-out and we can find a local repository, add it to the list.
    try {
      // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports,import/no-extraneous-dependencies
      const jsiiDotNetRuntime = require('@jsii/dotnet-runtime');
      localRepos.push(jsiiDotNetRuntime.repository);
    } catch {
      // Couldn't locate @jsii/dotnet-runtime, which is owkay!
    }

    // Filter out nonexistant directories, .NET will be unhappy if paths don't exist
    const existingLocalRepos = await filterAsync(localRepos, fs.pathExists);

    logging.debug('local NuGet repos:', existingLocalRepos);

    // Construct XML content.
    const configuration = xmlbuilder.create('configuration', { encoding: 'UTF-8' });
    const packageSources = configuration.ele('packageSources');

    const nugetOrgAdd = packageSources.ele('add');
    nugetOrgAdd.att('key', 'nuget.org');
    nugetOrgAdd.att('value', 'https://api.nuget.org/v3/index.json');
    nugetOrgAdd.att('protocolVersion', '3');

    existingLocalRepos.forEach((repo, index) => {
      const add = packageSources.ele('add');
      add.att('key', `local-${index}`);
      add.att('value', path.join(repo));
    });

    const xml = configuration.end({ pretty: true });

    // Write XML content to NuGet.config.
github sikuli / sieveable / lib / explain_query.js View on Github external
function parseInput(input, root, reservedWords, replaceFields) {
  // inject a root node
  let xml = builder.create(root),
    // parse the xml input
    $ = cheerio.load(input, OPTIONS);
  const children = _.filter($.root()[0].children, (c) => {
    return c.type === 'tag';
  });
  _.forEach(children, (elem) => {
    if (elem.children && elem.children.length > 0 &&
      _.indexOf(reservedWords, elem.name.toLowerCase()) > -1 && elem.type === 'tag') {
      const elementName = replaceFields ? replaceFields[elem.name] : elem.name,
        parent = xml.ele(elementName, elem.attribs, getElemData(elem));
      doChildren(elem, parent, replaceFields);
    }
    else if (_.indexOf(reservedWords, elem.name.toLowerCase()) > -1) {
      const elementName = replaceFields ? replaceFields[elem.name] : elem.name;
      xml.ele(elementName, elem.attribs, getElemData(elem));
    }
github socialtables / saml-protocol / lib / metadata.js View on Github external
function buildIDPMetadata(idp, signMetadata) {

	let metadata = xmlbuilder
		.begin({ separateArrayItems: true })
		.ele({
			"md:EntityDescriptor": [
				{
					"@ID": randomID(),
					"@entityID": idp.entityID,
					"@xmlns:md": namespaces.md,
					"@xmlns:ds": namespaces.ds
				},
				createIDPSSODescriptorJSON(idp)
			]
		})
		.end();

	// sign if necessary
	const signingCredential = credentials.getCredentialsFromEntity(idp, "signing")[0];
github natergj / excel4node / source / lib / worksheet / builder.js View on Github external
return new Promise((resolve, reject) => {

        let xmlProlog = '';
        let xmlString = '';
        let wsXML = xml.begin({
          'allowSurrogateChars': true,
        }, (chunk) => {
            xmlString += chunk;
        })

        .ele('worksheet')
        .att('mc:Ignorable', 'x14ac')
        .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')
        .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')
        .att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')
        .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');

        // Excel complains if specific elements on not in the correct order in the XML doc as defined in §M.2.2
        let promiseObj = { xml: wsXML, ws: ws };

        _addSheetPr(promiseObj)
github socialtables / saml-protocol / lib / request-construction.js View on Github external
// choose which consumption endpoint and method the assertion should
	// come in on
	const spBindingChoice = protocolBindings.chooseBinding(sp, "assert");

	// choose an agreed-upon name ID format, or use 'unspecified'
	const nameIDFormat = chooseFirstSharedNameIDFormat([idp, sp]) || protocol.NAMEIDFORMAT.UNSPECIFIED;
	const authnContext = {
		"samlp:RequestedAuthnContext": {
			"@Comparison": idp.authContext || DEFAULT_AUTH_CONTEXT,
			"saml:AuthnContextClassRef": protocol.AUTHNCONTEXT.PASSWORDPROTECTEDTRANSPORT
		}
	};

	// build request payload
	const authnRequest = xmlbuilder
		.begin({
			separateArrayItems: true
		})
		.ele({
			// request child elements are ordered
			"samlp:AuthnRequest": [{
				"@xmlns:samlp": namespaces.samlp,
				"@xmlns:saml": namespaces.saml,
				"@Version": "2.0",
				"@ID": requestID,
				"@IssueInstant": new Date().toISOString(),
				"@Destination": destinationURL,
				"@AssertionConsumerServiceURL": spBindingChoice.url,
				"@ProtocolBinding": spBindingChoice.longformURI,
			}, {
				"saml:Issuer": sp.entityID
github natergj / excel4node / src / workbook / builder / workbook.ts View on Github external
export default function addWorkbookXml(builder: IWorkbookBuilder) {
  const { wb, xlsx } = builder;

  const dataStream = getDataStream();
  const writer = xmlbuilder.streamWriter(dataStream);

  const xml = xmlbuilder.create('workbook', {
    version: '1.0',
    encoding: 'UTF-8',
    standalone: true,
  });
  xml.att('mc:Ignorable', 'x15');
  xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
  xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
  xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
  xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');

  // workbookPr (§18.2.28)
  const workbookPrEle = xml.ele('workbookPr');
  if (wb.workbookProperties.allowRefreshQuery) {
    workbookPrEle.att('allowRefreshQuery', boolToInt(wb.workbookProperties.allowRefreshQuery));
github natergj / excel4node / src / workbook / builder / wokbookRels.ts View on Github external
export default function addWorkbookXml(builder: IWorkbookBuilder) {
  const { wb, xlsx } = builder;

  const dataStream = getDataStream();
  const writer = xmlbuilder.streamWriter(dataStream);

  const xml = xmlbuilder
    .create('Relationships', {
      version: '1.0',
      encoding: 'UTF-8',
      standalone: true,
    })
    .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');

  xml
    .ele('Relationship')
    .att('Id', `rId${wb.sheets.size + 1}`)
    .att('Target', 'sharedStrings.xml')
    .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');

  // xml
github BabylonJS / Extensions / LeaderBoard / Zumo / service / node_modules / azure / node_modules / azure-common / lib / util / patch-xmlbuilder.js View on Github external
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

'use strict';

var XMLBuilder = require('xmlbuilder/lib/XMLBuilder');

// Patch xmlbuilder to allow Unicode surrogate pair code
// points in XML bodies

XMLBuilder.prototype.assertLegalChar = function(str) {
  var chars, chr;
  chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/;
  chr = str.match(chars);
  if (chr) {
    throw new Error('Invalid character (' + chr + ') in string: ' + str);
  }
};
github Azure / azure-sdk-for-node / lib / common / lib / util / patch-xmlbuilder.js View on Github external
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

'use strict';

var XMLBuilder = require('xmlbuilder/lib/XMLBuilder');

// Patch xmlbuilder to allow Unicode surrogate pair code
// points in XML bodies

XMLBuilder.prototype.assertLegalChar = function(str) {
  var chars, chr;
  chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/;
  chr = str.match(chars);
  if (chr) {
    throw new Error('Invalid character (' + chr + ') in string: ' + str);
  }
};
github Azure / azure-sdk-for-java / ClientRuntimes / NodeJS / ClientRuntime / lib / util / patch-xmlbuilder.js View on Github external
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

'use strict';

var XMLBuilder = require('xmlbuilder/lib/XMLBuilder');

// Patch xmlbuilder to allow Unicode surrogate pair code
// points in XML bodies

XMLBuilder.prototype.assertLegalChar = function(str) {
  var chars, chr;
  chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/;
  chr = str.match(chars);
  if (chr) {
    throw new Error('Invalid character (' + chr + ') in string: ' + str);
  }
};

xmlbuilder

An XML builder for node.js

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis