英文:
NIFI Reading XML node value
问题
我需要读取节点值"ReferenceDocumentNumber",其值为"SI-000000614"。我正在使用Nifi中的EvaluateXpath处理器。我的设置如下图所示:
我甚至尝试使用/@ReferenceDocument
,但未能获取节点值。请在这里提供帮助。
英文:
I have the following xml:
<?xml version="1.0" encoding="UTF-8"?><ns1:SalesOrderMessages mlns:ns1="http://corpintra.net/pi/CBFC_GLOBAL_SAP_APPL/SalesOrder" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<SalesOrder>
<MessageProcessingInformation>
<SendingSystemID>SMS_0175</SendingSystemID>
</MessageProcessingInformation>
<Header>
<SalesDocumentType>YPO0</SalesDocumentType>
<SalesOrganization>7002</SalesOrganization>
<DistributionChannel>00</DistributionChannel>
<RequestedDeliveryDate>2023-06-15</RequestedDeliveryDate>
<CustomerPurchaseOrderDate>2023-06-15</CustomerPurchaseOrderDate>
<Incoterms1>EXW</Incoterms1>
<Incoterms2>Ex Works</Incoterms2>
<PaymentTerms>E007</PaymentTerms>
<CustomerPurchaseOrderNumber>990831 </CustomerPurchaseOrderNumber>
<ReferenceDocumentNumber>SI-000000614</ReferenceDocumentNumber>
<ServicesRenderedDate>2023-06-15</ServicesRenderedDate>
<LogisticData>
<SourceReferenceDocumentNumber>SI-000000614</SourceReferenceDocumentNumber>
<SourceSalesOrderNumber>SO-000050562</SourceSalesOrderNumber>
</LogisticData>
</Header>
<Items>
<ItemNumber>10</ItemNumber>
............
I need to read the node value "ReferenceDocumentNumber", which is "SI-000000614"
I am using EvaluateXpath processor in Nifi. And my setting is attached in the image
I had even tried with /@ReferenceDocument. But not getting the node value. Please help here.
答案1
得分: 0
你错过了根元素 ns1:SalesOrderMessages
。以下是适用于我的部分:
输入
<?xml version="1.0" encoding="UTF-8"?>
<ns1:SalesOrderMessages mlns:ns1="http://corpintra.net/pi/CBFC_GLOBAL_SAP_APPL/SalesOrder" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<SalesOrder>
<MessageProcessingInformation>
<SendingSystemID>SMS_0175</SendingSystemID>
</MessageProcessingInformation>
<Header>
<SalesDocumentType>YPO0</SalesDocumentType>
<SalesOrganization>7002</SalesOrganization>
<DistributionChannel>00</DistributionChannel>
<RequestedDeliveryDate>2023-06-15</RequestedDeliveryDate>
<CustomerPurchaseOrderDate>2023-06-15</CustomerPurchaseOrderDate>
<Incoterms1>EXW</Incoterms1>
<Incoterms2>Ex Works</Incoterms2>
<PaymentTerms>E007</PaymentTerms>
<CustomerPurchaseOrderNumber>990831 </CustomerPurchaseOrderNumber>
<ReferenceDocumentNumber>SI-000000614</ReferenceDocumentNumber>
<ServicesRenderedDate>2023-06-15</ServicesRenderedDate>
<LogisticData>
<SourceReferenceDocumentNumber>SI-000000614</SourceReferenceDocumentNumber>
<SourceSalesOrderNumber>SO-000050562</SourceSalesOrderNumber>
</LogisticData>
</Header>
</SalesOrder>
</ns1:SalesOrderMessages>
XPath 表达式
/*:SalesOrderMessages/SalesOrder/Header/ReferenceDocumentNumber
或
//ReferenceDocumentNumber
输出
SI-000000614
英文:
You missed the root element ns1:SalesOrderMessages
. This works for me:
Input
<?xml version="1.0" encoding="UTF-8"?>
<ns1:SalesOrderMessages mlns:ns1="http://corpintra.net/pi/CBFC_GLOBAL_SAP_APPL/SalesOrder" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<SalesOrder>
<MessageProcessingInformation>
<SendingSystemID>SMS_0175</SendingSystemID>
</MessageProcessingInformation>
<Header>
<SalesDocumentType>YPO0</SalesDocumentType>
<SalesOrganization>7002</SalesOrganization>
<DistributionChannel>00</DistributionChannel>
<RequestedDeliveryDate>2023-06-15</RequestedDeliveryDate>
<CustomerPurchaseOrderDate>2023-06-15</CustomerPurchaseOrderDate>
<Incoterms1>EXW</Incoterms1>
<Incoterms2>Ex Works</Incoterms2>
<PaymentTerms>E007</PaymentTerms>
<CustomerPurchaseOrderNumber>990831 </CustomerPurchaseOrderNumber>
<ReferenceDocumentNumber>SI-000000614</ReferenceDocumentNumber>
<ServicesRenderedDate>2023-06-15</ServicesRenderedDate>
<LogisticData>
<SourceReferenceDocumentNumber>SI-000000614</SourceReferenceDocumentNumber>
<SourceSalesOrderNumber>SO-000050562</SourceSalesOrderNumber>
</LogisticData>
</Header>
</SalesOrder>
</ns1:SalesOrderMessages>
Xpath Expression
/*:SalesOrderMessages/SalesOrder/Header/ReferenceDocumentNumber
or
//ReferenceDocumentNumber
Output
SI-000000614
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论