1
如何使用XmlNodePrinter将对象的输出写入soapUI中的测试步骤(Soaprequest)。如何使用Groovy XmlNodePrinter编写输出?
我有下面的groovy脚本,其中我有一个输入XML文件。我执行文件操作,然后想用xmlnodeprinter写入对象到soapUI中的测试步骤(soaprequest)(以粗体突出显示...不知道应该用什么方式代替 - )
我试过写到工作的一个外部文件(以绿色高亮显示)
def alert = com.eviware.soapui.support.UISupport;
//Define a file pointer for groovy to handle the file operations.
def inputFile = new File("V:\\Sample\\Sample.xml")
if(!inputFile.exists())
{
//Display an alert if the file is not found.
alert.showInfoMessage("Input File 'Sample.xml' not found!");
}
else
{
xml=new XmlParser().parseText(inputFile.text)
def nodeToDel=xml.A.B.find{[email protected]='1'}
def parent = nodeToDel.parent()
parent.remove(nodeToDel)
//new XmlNodePrinter(new PrintWriter(new FileWriter(new File('V:\\Sample\\e.xml')))).print(parent)
new XmlNodePrinter(new PrintWriter(new FileWriter(---))).print(parent)
}
对不起Vamsi。我是这个网站的新手,正在慢慢地学习网站的功能:-)我现在想出了你如何接受答案。 – 2012-07-25 10:04:29