[英]XML 1.1 number version is not valid with xml document
I have a xml document like this 我有一个这样的xml文档
<?xml version="1.1" encoding="UTF-8" standalone="yes"?>
<p:FatturaElettronica versione="1.1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://www.fatturapa.gov.it/sdi/fatturapa/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
<IdPaese>IT</IdPaese>
...
If i use: 如果我使用:
Dim doc As New XmlDocument()
doc.Load(filePath)
I receive an error: 我收到一个错误:
1.1 is not a valid version
1.1不是有效的版本
Why, how can i do for read xml with this version? 为什么,我要如何使用此版本读取xml?
Thanks 谢谢
Give this a try. 试试看。 It assumes that not having the first line has no consequences.
它假定没有第一行没有任何后果。
Dim fileLines As List(Of String) = IO.File.ReadAllLines(filePath).ToList
fileLines.RemoveAt(0)
Dim fileAsString As String = String.Join(Environment.NewLine, fileLines)
Dim xe As XElement = XElement.Parse(fileAsString)
Dim doc As New XmlDocument()
doc.Load(xe.CreateReader)
If you download an example of file FatturaPA from http://www.fatturapa.gov.it/export/fatturazione/it/a-3.htm you will notice that xml version is 1.0. 如果您从http://www.fatturapa.gov.it/export/fatturazione/it/a-3.htm下载文件FatturaPA的示例,您会注意到xml版本是1.0。
<?xml version="1.0" encoding="UTF-8"?>
<p:FatturaElettronica versione="1.1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://www.fatturapa.gov.it/sdi/fatturapa/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
So maybe your file is not correct. 因此,也许您的文件不正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.