I, in denen bekommen Flowfile wollen, ist Komponenten xml und aktualisieren eine der TagValue i es in benutzerdefinierten nifi Prozessor Code machen, ich habe Code wie folgt:Datei nicht gefunden Ausnahme
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");
aber es trows Datei nicht Exception Exception gefunden, was sollte ich ändern, damit dieser Code funktioniert? Ps Ich kann den Pfad für Flowfile nicht verwenden
Sie haben es in Ihrem Code außer der Weg, wie man aus der Flussdatei streamen kann. (ich erwähnte in Antwort) – daggett
Ich kann nicht schließen, fstream nach all diesen Operationen meine ich: DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder-Builder = builderFactory.newDocumentBuilder(); Dokument xmlDocument = builder.parse (inputSource); XPath xPath = XPathFactory.newInstance(). NewXPath(); NodeList myNodeList = (NodeList) xPath.compile ("// runAs/text()") .evaluate (Flussdatei, XPathConstants.NODESET); myNodeList.item (0) .setNodeValue ("false"); –
Sie können den Stream schließen, unmittelbar nachdem der Stream geparst wurde: 'builder.parse (inputSource)' – daggett