Skip to content

Commit fab344a

Browse files
CobusTmbostock
andauthored
add xml support for file attachments (#246)
* add xml support for file attachments * Update src/fileAttachment.js Co-authored-by: Mike Bostock <[email protected]> Co-authored-by: Mike Bostock <[email protected]>
1 parent 3f155c9 commit fab344a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/fileAttachment.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ class AbstractFile {
6464
const [JSZip, buffer] = await Promise.all([requireDefault(jszip.resolve()), this.arrayBuffer()]);
6565
return new ZipArchive(await JSZip.loadAsync(buffer));
6666
}
67+
async xml(mimeType = "application/xml") {
68+
return (new DOMParser).parseFromString(await this.text(), mimeType);
69+
}
70+
async html() {
71+
return this.xml("text/html");
72+
}
6773
}
6874

6975
class FileAttachment extends AbstractFile {

0 commit comments

Comments
 (0)