我有一个具有结构的 xml:
<?xml version="1.0" encoding="utf-8" ?>
<XYZInquiry>
<Source>ABC</Source>
<Info>19991234</Info>
<RawData>
<EmailAddress>abc@email.com</EmailAddress>
</RawData>
</XYZInquiry>
和相应的 XSD 进行验证:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema id="XYZInquiry" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="XYZInquiry">
<xsd:complexType>
<xsd:all>
<xsd:element name="Source" minOccurs="1" maxOccurs="1" type="xsd:string" />
<xsd:element name="Info" minOccurs="1" maxOccurs="1" type="xsd:string" />
<xsd:element name="RawData" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EmailAddress" minOccurs="0" maxOccurs="1"/>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
我需要读取信息标签并根据前 4 位数字,我需要在 RawData 标签上设置条件。即,如果信息值以 1234 开头,则允许 RawData 标记,否则无效。好心提醒。