-1

在 HIEOS 中访问 xtest (testplan.xml) 时,通过 . 我收到以下错误。

FatalError (step null) : Could not create XMLStreamReader (in Util.parse_xml()) from string: o;?<?xml version="1.0" encoding="UTF-8"?>

如何解决?

注意:我已经使用 C#.NET 修改了 XML 值;在修改之前,xtest 工作正常。可能是什么原因?

其他详细信息:我使用以下 C# 代码测试了相同的 XML 文件。

XmlTextReader tr = new XmlTextReader(@"D:\hieos-1.2\xtest\test\scripts\testdata\trial3\submit\testplan.xml");
XmlValidatingReader r = new XmlValidatingReader(tr);
r.ValidationType = ValidationType.None;
try
{
    while (r.Read()) ;
}
catch (XmlException e)
{
    Console.WriteLine(e.Message);
    Console.WriteLine("Exception object Line, pos: (" + e.LineNumber + "," + e.LinePosition + ")");
    Console.WriteLine("Exception source URI: (" + e.SourceUri + ")");
    Console.WriteLine("XmlReader Line, pos: (" + tr.LineNumber + "," + tr.LinePosition + ")");
}

没有引发异常。我认为XMLStreamReader检查 XML 文件中的其他内容。

我的 XML 文件的内容是,

<?xml version="1.0" encoding="UTF-8"?>
<TestPlan>
<Test>vsmallpnr/submit</Test>
 <TestStep id="submit_docs">
    <NewPatientId/>
    <ExpectedStatus>Success</ExpectedStatus>
    <ProvideAndRegisterTransaction>
        <XDSb/>
    <AssignUuids/>
        <MetadataFile>sor.xml</MetadataFile>
        <Document id="Document01">test_pdf_doc.pdf</Document>
        <Document id="Document02">test_hitsp_c32.xml</Document>
    <Document id="Document03">test_txt_doc.txt</Document>
    <Document id="Document04">test_txt_doc.txt</Document>
    <Document id="Document05">test_txt_doc.txt</Document>
    </ProvideAndRegisterTransaction>
</TestStep>
<TestStep id="reset_patient_id">
    <NewPatientId/>
</TestStep>

解决方案: 我已使用UTF-8 编码更改了 XML 保存方法。然后错误就解决了。感谢大家的支持。

4

2 回答 2

0

in xtest的实际问题XMLStreamReader是由于 C# 的编码技术。

一旦更改了 C# 代码的编码技术,错误就会得到解决。

using (TextWriter sw = new StreamWriter(@"D:\hieos-1.2\xtest\test\scripts\testdata\trial3\submit\testplan.xml", false, Encoding.Default))
{                    
    xmlDoc.Save(sw);
 }

XMLDocument如果我们没有提到编码类型,它就是在实际内容之前创建空白。这就是 Xtest (Java) 抛出 XMLStreamReader 错误的原因。

于 2013-09-16T13:26:02.137 回答
0

加载 Xml 时,XmlWriter重要StreamWriter的是要向 xml 提及您需要的编码。您加载 UTF-8 xml 的事实并不意味着将保存 UTF-8 xml。利用:

var doc = new XmlDocument();
XmlElement root = doc.CreateElement("myRoot");
doc.AppendChild(root);
root.InnerText = "myInnerText";
using(TextWriter sw = new StreamWriter("C:\\output.txt", false, Encoding.UTF8)) //Set encoding
{
    doc.Save(sw);
}
于 2013-09-16T08:51:30.813 回答