feat(xml): add XML tools for validation, beautification, and viewing

This commit is contained in:
AshAnand34
2025-07-08 12:56:31 -07:00
parent d47fc0812d
commit 6b2070b39f
20 changed files with 372 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
import { InitialValuesType } from './types';
import { XMLValidator } from 'fast-xml-parser';
export function validateXml(
input: string,
_options: InitialValuesType
): string {
const result = XMLValidator.validate(input);
if (result === true) {
return 'Valid XML';
} else if (typeof result === 'object' && result.err) {
return `Invalid XML: ${result.err.msg} (line ${result.err.line}, col ${result.err.col})`;
} else {
return 'Invalid XML: Unknown error';
}
}