开发者

XDocument: can you skip loading the <!DOCTYPE

开发者 https://www.devze.com 2023-01-25 16:01 出处:网络
For Each file In My.Computer.FileSystem.GetFiles(inputFolder) doc = XDocument.Load(file) Next This crashes with a \"\'[\' is an unexpected token. Blah,blah,blah\"
    For Each file In My.Computer.FileSystem.GetFiles(inputFolder)
        doc = XDocument.Load(file)
    Next

This crashes with a "'[' is an unexpected token. Blah,blah,blah"

It's obviously choking on the first line which is....

<!DOCTYPE RCWChapter PUBLIC "-//L开发者_JAVA百科SC//DTD RCW Chapter for Authoring//EN" [] >

1st, is that INVALID XML? Why is it hanging on the "[" ?

2nd, Can I somehow load the XML document, but skip the DOCTYPE? Should I load it as a stream? string.replace it?


Try This : you can remove the internal subset from the DTD by setting the XDocumentType.InternalSubset property to null

XDocument document = ...;
if (document.DocumentType != null)
document.DocumentType.InternalSubset = null;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号