我检查了此链接中的示例,但它可以解决其他问题,删除我传递给的ID的节点。
Removing XML Nodes using XSLT?
例如
<Message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="example.lessson.1:v3" >
<dt:Header>
<dt:MessageId>12121212121212121</dt:MessageId>
<dt:Timestamp>2013-01-01T00:00:00</dt:Timestamp>
<dt:MessageType>2</dt:MessageType>
</dt:Header>
<dt:Body >
<Rowsets>
<Rowset>
<Row>
<FirstName>Michael</FirstName>
<LastName>David</LastName>
<Phone>1234567890</Phone>
<ID>111111<ID>
</Row>
<Row>
<FirstName>David</FirstName>
<LastName>Michael</LastName>
<Phone>01234567890</Phone>
<ID>222222<ID>
</Row>
<Row>
<FirstName>Yang</FirstName>
<LastName>Christina</LastName>
<Phone>2345678901</Phone>
<ID>333333<ID>
</Row>
<Row>
<FirstName>Grey</FirstName>
<LastName>Meredith</LastName>
<Phone>3456789012</Phone>
<ID>4444444<ID>
</Row>
<Row>
<FirstName>David</FirstName>
<LastName>Shepherd</LastName>
<Phone>5678901234</Phone>
<ID>5555555<ID>
</Row>
</Rowset>
</Rowsets>
</body>
我需要运行一个XSLt,它将使用ID i传递并创建一个新的xml,只保留该节点和头部以及其他正文标记 例如,如果我传递111111,222222,333333作为输入,则输出应为
<Message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="example.lessson.1:v3" >
<dt:Header>
<dt:MessageId>12121212121212121</dt:MessageId>
<dt:Timestamp>2013-01-01T00:00:00</dt:Timestamp>
<dt:MessageType>2</dt:MessageType>
</dt:Header>
<dt:Body >
<Rowsets>
<Rowset>
<Row>
<FirstName>Michael</FirstName>
<LastName>David</LastName>
<Phone>1234567890</Phone>
<ID>111111<ID>
</Row>
<Row>
<FirstName>David</FirstName>
<LastName>Michael</LastName>
<Phone>01234567890</Phone>
<ID>222222<ID>
</Row>
<Row>
<FirstName>Yang</FirstName>
<LastName>Christina</LastName>
<Phone>2345678901</Phone<ID>333333<ID>
</Row>
</Rowset>
</Rowsets>
</body>