Check for XML errors using JavaScript

前端 未结 5 1642
耶瑟儿~
耶瑟儿~ 2020-12-24 13:36

Question: How do I syntax-check my XML in modern browsers (anything but IE)?

I\'ve seen a page on W3Schools which includes an XML syntax-checker. I don\'t kno

5条回答
  •  隐瞒了意图╮
    2020-12-24 14:18

    You can also use the package fast-xml-parser, this package have a validate check for xml files:

    import { validate, parse } from 'fast-xml-parser';
    
    if( validate(xmlData) === true) {
      var jsonObj = parse(xmlData,options);
    }
    

提交回复
热议问题