0
我想flowfile其中是XML组件和更新tagvalue之一,我做这里面的自定义nifi处理器的代码,我有这样的代码:文件未发现异常
flowFile = session.putAttribute(flowFile,"filename",file.getName() + ".xml");
InputSource inputSource = new InputSource((InputStream) flowFile);
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDocument = builder.parse(inputSource);
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList myNodeList = (NodeList) xPath.compile("//runAs/text()")
.evaluate(flowFile, XPathConstants.NODESET);
myNodeList.item(0).setNodeValue("false");
但trows文件未发现异常异常,我应该改变什么使这段代码工作ps我不能使用流文件的路径
你没有在你的代码除如何从流文件中获取流。 (我在回答中提到) – daggett
我不能关闭fstream后所有这些操作我的意思是:DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document xmlDocument = builder.parse(inputSource); XPath xPath = XPathFactory.newInstance()。newXPath(); NodeList myNodeList =(NodeList)xPath.compile(“// runAs/text()”) .evaluate(flowFile,XPathConstants.NODESET); myNodeList.item(0).setNodeValue(“false”); –
你可以在流解析后关闭流:'builder.parse(inputSource)' – daggett