我坚持这个问题2天了。我只想提取图像中标记的数据,以便通过XSLT进行转换。我也在这个问题中给出了XML文件。对不起,如果这似乎是一个非常愚蠢的问题。像// PartyInformation / Buyer / Contact // Name这样的类似路径在文档中起作用。但是// PartyInformation / Buyer / Contact //姓名不起作用
到目前为止,我已经尝试过,
非常感谢任何帮助!
谢谢。
<?xml version="1.0" encoding="utf-16"?>
<Invoice xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://Companydomain.Schema">
<InvoiceHeader xmlns="">
<InvoiceDate />
<InvoiceDueDate />
<InvoiceNo />
<AllowDuplicates>false</AllowDuplicates>
<AddAttachment>false</AddAttachment>
<UserApprovedSubmission>false</UserApprovedSubmission>
<SellerOrderNumber />
<PurchaseOrderNumber />
<NumberOfLines>1</NumberOfLines>
<InvoiceType>
<Type>ServiceInvoice</Type>
</InvoiceType>
<SourceInvoiceType>
<Type>ServiceInvoice</Type>
</SourceInvoiceType>
<DeliveryInformation>
<DeliveryInstructions />
</DeliveryInformation>
</InvoiceHeader>
<PartyInformation xmlns="">
<Seller>
<Party xmlns="http://Companydomain.Schema">
<PartyId xmlns="" />
<ExternalSystemId xmlns="" />
<Name xmlns="" />
<GBN xmlns="" />
</Party>
<Address xmlns="http://Companydomain.Schema" />
</Seller>
<Buyer>
<Party xmlns="http://Companydomain.Schema">
<PartyId xmlns="">2</PartyId>
<ExternalSystemId xmlns="" />
<Name xmlns="" />
<GBN xmlns="" />
</Party>
<Address xmlns="http://Companydomain.Schema" />
<Contact xmlns="http://Companydomain.Schema">
<Name xmlns="">Mr Parminder Singh</Name>
<Phone xmlns="" />
<Fax xmlns="" />
<Email xmlns="" />
</Contact>
<SuppliersCustomerId />
</Buyer>
<ShipTo>
<Party xmlns="http://Companydomain.Schema">
<Name xmlns="" />
</Party>
<Address xmlns="http://Companydomain.Schema" />
</ShipTo>
<ShipFrom>
<Party xmlns="http://Companydomain.Schema">
<Name xmlns="" />
</Party>
<Address xmlns="http://Companydomain.Schema" />
</ShipFrom>
<Payer>
<Party xmlns="http://Companydomain.Schema">
<Name xmlns="" />
</Party>
<Address xmlns="http://Companydomain.Schema" />
</Payer>
</PartyInformation>
</Invoice>
&#13;
答案 0 :(得分:2)
这是因为Contact
节点位于http://Companydomain.Schema
命名空间下。尝试:
//PartyInformation/Buyer/*[local-name()='Contact']/Name
或者,您可以在xslt中注册命名空间,
xmlns:com="http://Companydomain.Schema"
并拥有xpath
//PartyInformation/Buyer/com:Contact/Name