mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2025-07-28 02:32:11 +10:00
chore: update public repo
This commit is contained in:
parent
e0109980c0
commit
e7c9507247
25 changed files with 5364 additions and 0 deletions
20
utils/xml.ts
Normal file
20
utils/xml.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import type { ChildNode } from 'domhandler'
|
||||
import { DomHandler } from 'domhandler'
|
||||
import { Parser } from 'htmlparser2'
|
||||
|
||||
export function xmlToDom(xml: string) {
|
||||
let _error: Error | null = null
|
||||
let _dom: ChildNode[] | null = null
|
||||
|
||||
const handler = new DomHandler((error, dom) => {
|
||||
_error = error
|
||||
_dom = dom
|
||||
})
|
||||
const parser = new Parser(handler)
|
||||
parser.write(xml)
|
||||
parser.end()
|
||||
|
||||
if (_error) throw _error
|
||||
|
||||
return _dom!
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue