我试图将XML转换为看起来像另一个XML的输出。但我不确定如何打印“正斜杠”。 我需要输出也有标签。 这是我必须转换尝试将XML文件转换为不同的xml文件
<ItemDetails>
<Item>
<Code>3390876231</Code>
<Customer id='1055'>
<FirstName>John</FirstName>
<MiddleName>M</MiddleName>
<LastName>Crusoe</LastName>
<Title>Mr.</Title>
<Address>
<HouseNumber>House11</HouseNumber>
<Street>St.Marks Street</Street>
<Country>UK</Country>
<ContactNumber>
<PhoneNumber1>0657385245</PhoneNumber1>
<PhoneNumber2>0657385211</PhoneNumber2>
</ContactNumber>
<PostalCode>3452DD</PostalCode>
</Address>
</Customer>
<Name>Romeo and Juliet</Name>
<Type>compact disc</Type>
<Author>Rostropovich</Author>
<ListPrice>18.98</ListPrice>
<SellPrice>13.99</SellPrice>
<Cost>9.92</Cost>
</Item>
<Item>
<Code>3390007231</Code>
<Customer id='1056'>
<FirstName>Kayne</FirstName>
<MiddleName/>
<LastName>West</LastName>
<Title>Mr.</Title>
<Address>
<HouseNumber>House78</HouseNumber>
<Street>Pittsburg Street</Street>
<Country>USA</Country>
<ContactNumber>
<PhoneNumber1>0690885245</PhoneNumber1>
<PhoneNumber2>0690785211</PhoneNumber2>
</ContactNumber>
<PostalCode>3882PP</PostalCode>
</Address>
</Customer>
<Name>XSLT</Name>
<Type>book</Type>
<Author>Tidwell</Author>
<ListPrice>49.95</ListPrice>
<SellPrice>34.99</SellPrice>
<Cost>22.92</Cost>
</Item>
<Item>
<Code>3390876001</Code>
<Customer id='1057'>
<FirstName>Martha</FirstName>
<MiddleName>W</MiddleName>
<LastName>Hamilton</LastName>
<Title>Mrs.</Title>
<Address>
<HouseNumber>House456</HouseNumber>
<Street>Alfred Street</Street>
<Country>UK</Country>
<ContactNumber>
<PhoneNumber1>0659985245</PhoneNumber1>
<PhoneNumber2>0657300011</PhoneNumber2>
</ContactNumber>
<PostalCode>3786CD</PostalCode>
</Address>
</Customer>
<Name>The Little Schemer</Name>
<Type>book</Type>
<Author>Friedman</Author>
<Author>Felleisen</Author>
<ListPrice>29.95</ListPrice>
<SellPrice>26.99</SellPrice>
<Cost>17.92</Cost>
</Item>
<Item>
<Code>3399996231</Code>
<Customer id='1058'>
<FirstName>Harold</FirstName>
<MiddleName/>
<LastName>Crossley</LastName>
<Title>Mr.</Title>
<Address>
<HouseNumber>House909</HouseNumber>
<Street>Beaumont Street</Street>
<Country>UK</Country>
<ContactNumber>
<PhoneNumber1>0656665245</PhoneNumber1>
<PhoneNumber2>0657385200</PhoneNumber2>
</ContactNumber>
<PostalCode>3772DI</PostalCode>
</Address>
</Customer>
<Name>A Tribute to People’s Princess: Diana</Name>
<Type>book</Type>
<Author>Peter Donelli</Author>
<ListPrice>65.98</ListPrice>
<SellPrice>78.99</SellPrice>
<Cost>60.92</Cost>
</Item>
<Item>
<Code>33908755118</Code>
<Customer id='1059'>
<FirstName>Donna</FirstName>
<MiddleName>H</MiddleName>
<LastName>Miller</LastName>
<Title>Miss</Title>
<Address>
<HouseNumber>House998</HouseNumber>
<Street>Maple Street</Street>
<Country>USA</Country>
<ContactNumber>
<PhoneNumber1>8002255288</PhoneNumber1>
<PhoneNumber2>8011155288</PhoneNumber2>
</ContactNumber>
<PostalCode>3662DD</PostalCode>
</Address>
</Customer>
<Name>KingMozart</Name>
<Type>compact disc</Type>
<Author>Donald Runnicles</Author>
<ListPrice>20.98</ListPrice>
<SellPrice>18.99</SellPrice>
<Cost>22.92</Cost>
</Item>
</ItemDetails>
这是输出应该如何将XML文件。要嵌套的标签被删除并按顺序同步。
<ItemDetails>
<Item>
<Code>3390876231</Code>
<CustomerID>1055</CustomerID>
<FullName>Mr.John M Crusoe</FullName>
<Address>House11,St.Marks Street,UK</Address>
<ContactNumbers>0657385245,0657385211</ContactNumbers>
<PostalCode>3452DD</PostalCode>
<ItemName>Romeo and Juliet</ItemName>
<ItemType>compact disc</ItemType>
<Author>Rostropovich</Author>
<list-price>18.98</list-price>
<sell-price>13.99</sell-price>
<cost-price>9.92</cost-price>
<profit>4.07</profit>
</Item>
<Item>
<Code>3390007231</Code>
<CustomerID>1056</CustomerID>
<FullName>Mr.Kayne West</FullName>
<Address>House78,Pittsburg Street,USA</Address>
<ContactNumbers>0690885245</ContactNumbers>
<PostalCode>3882PP</PostalCode>
<ItemName>XSLT</ItemName>
<ItemType>book</ItemType>
<Author>Tidwell</Author>
<list-price>49.95</list-price>
<sell-price>34.99</sell-price>
<cost-price>22.92</cost-price>
<profit>12.07</profit>
</Item>
</ItemDetails>
这是我的代码。我不知道如何将标签输出
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<html>
<body>
<xsl:for-each select="Item">
\t <p><Code><xsl:value-of select="Code"/></Code></br>
\t <CustomerID><xsl:value-of select="Customer"/></CustomerID></br>
\t <xsl:for-each select="Customer">
\t <CustomerID><xsl:value-of select="Customer/@id"/></CustomerID></br>
\t <FullName><xsl:value-of select="Title"/> <xsl:value-of select="FirstName"/> <xsl:value-of select="MiddleName"/> <xsl:value-of select="LastName"/></FullName> </br>
\t <Address>
\t <xsl:for-each select="Address">
\t <xsl:value-of select="HouseNumber"/> <xsl:value-of select="Street"/> <xsl:value-of select="Country"/> </Address> </br>
\t <ContactNumbers><xsl:for-each select="ContactNumber"> <xsl:value-of select="PhoneNumber1"/> , <xsl:value-of select="PhoneNumber2"/> </xsl:for-each></ContactNumbers> </br>
\t <PostalCode><xsl:value-of select="PostalCode"/></PostalCode></br>
\t </xsl:for-each>
\t </xsl:for-each>
\t <ItemName><xsl:value-of select="Name"/></ItemName></br>
\t <ItemType><xsl:value-of select="Type"/></ItemType></br>
\t <Author><xsl:value-of select="Author"/></Author></br>
\t <list-price><xsl:value-of select="ListPrice"/></list-price></br>
\t <sell-price><xsl:value-of select="SellPrice"/><sell-price></br>
\t <cost-price><xsl:value-of select="Cost"/></cost-price></br></p>
\t </xsl:for-each>
</body>
</html>
</xsl:stylesheet>
\t \t
您已将所需输出显示为XML,但您尝试使用的XSLT包含'html'。你需要XML还是HTML作为输出? –
@AniketV我希望XSLT的输出看起来像xml。 –
那么您发布的XSLT代码究竟与您的问题有什么关系?你只是发布任何代码? – Tomalak