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