---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [xml-validation](../index.md) / validateXmlFile

# Function: validateXmlFile()

> **validateXmlFile**(`filePath`, `options`, `explicit`): `Promise`\<[`XmlValidationResult`](../interfaces/XmlValidationResult.md)\>

Defined in: [packages/b2c-tooling-sdk/src/xml-validation/validate.ts:94](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/b7ec7d4a1464ef7bbb6a5757ffd6f99a18a31bf6/packages/b2c-tooling-sdk/src/xml-validation/validate.ts#L94)

Validate one XML file against a B2C Commerce schema.

Without a `schema` option, the schema is chosen from the namespace of the root element (for example,
`http://www.demandware.com/xml/impex/catalog/2006-10-31` selects `catalog`). A well-formed file with no
matching schema is skipped; a malformed one fails.

## Parameters

### filePath

`string`

Path to the XML file

### options

[`ValidateXmlOptions`](../interfaces/ValidateXmlOptions.md) = `{}`

Validation options

### explicit

`boolean` = `false`

When true, a file with no matching schema fails instead of being skipped

## Returns

`Promise`\<[`XmlValidationResult`](../interfaces/XmlValidationResult.md)\>

## Throws

XmlSchemaLoadError when a custom `.xsd` does not compile

## Example

```typescript
const result = await validateXmlFile('catalog.xml');
if (!result.valid) {
  for (const error of result.errors) console.log(`line ${error.line}: ${error.message}`);
}
```
