我想使用XSLT将XML转换为CSV,但是在针对我的输入应用标题为
XML To CSV XSLT的SO线程中的XSL时:
<WhoisRecord> <DomainName>127.0.0.1</DomainName> <RegistryData> <AbuseContact> <Email>abuse@iana.org</Email> <Name>Internet Corporation for Assigned Names and Number</Name> <Phone>+1-310-301-5820</Phone> </AbuseContact> <AdministrativeContact i:nil="true"/> <BillingContact i:nil="true"/> <CreatedDate/> <RawText>...</RawText> <Registrant> <Address>4676 Admiralty Way,Suite 330</Address> <City>Marina del Rey</City> <Country>US</Country> <Name>Internet Assigned Numbers Authority</Name> <PostalCode>90292-6695</PostalCode> <StateProv>CA</StateProv> </Registrant> <TechnicalContact> <Email>abuse@iana.org</Email> <Name>Internet Corporation for Assigned Names and Number</Name> <Phone>+1-310-301-5820</Phone> </TechnicalContact> <UpdatedDate>2010-04-14</UpdatedDate> <ZoneContact i:nil="true"/> </RegistryData> </WhoisRecord>
我最终得到:
abuse@iana.orgInternet Corporation for Assigned Names and Number+1-310-301-5820,...,4676 Admiralty Way,Suite 330Marina del ReyUSInternet Assigned Numbers Authority90292-6695CA,abuse@iana.orgInternet Corporation for Assigned Names and Number+1-310-301-5820,2010-04-14,
我的问题是,生成的转换缺少节点(如包含IP地址的DomainName元素),并且一些子节点连接而没有逗号(如AbuseContact的子节点).
我希望以CSV格式看到所有XML输出,以及字符串:“abuse@iana.orgInternet Corporation for Assigned Names and Number 1-310-301-5820”,用逗号分隔.
我的XSL非常生疏.感谢您的帮助.