Reputation: 1
I have an Xml
<input Inputxml="<Order..<LinePPlineNO="1@quot;Line/> >" >
How do i remove some part of string using xsl .. for eg I need to remove a whole string from <
to >
for a PPline 1
I need to splie the string in 3 parts remove the string from lt to gt and merge the part 1na dpart 3 of string
<Test Attrib1="b" Attrib2="C" Inputxml="
<OrderLine OrderedQty="1" PrimeLineNo="1" ShipNode="ABC" $gt;
</OrderLine $gt;
<OrderLine OrderedQty="1" PrimeLineNo="2" ShipNode="ABC" $gt;
</OrderLine $gt;" />
For example I may have 100 Order lines but I need to find the one with Prime line 1 and remove it .. So if I have to remeove a line I have to remove from lt; to gt;
Upvotes: 0
Views: 78
Reputation: 117140
Your example is confusing. If you have an XML input such as:
<input Inputxml="<order><Line PPlineNO="1">Bingo</Line></order>"/>
where the Inputxml
attribute holds the escaped XML:
<order><Line PPlineNO="1">Bingo</Line></order>
you can use:
<xsl:template match="input">
<result>
<xsl:value-of select="substring-before(substring-after(@Inputxml, 'PPlineNO="1">'), '</Line>')" />
</result>
</xsl:template>
to get:
<result>Bingo</result>
Note that is not a good way to parse XML (or rather what used to be XML). It would be much smarter to unescape it first, then parse it as XML. In XSLT 3.0, you can use the parse-xml()
function for this. In XSLT 1.0/2.0, you can do:
<xsl:value-of select="@Inputxml" disable-output-escaping="yes"/>
save the result to a file, and process the resulting file using another XSLT stylesheet.
Upvotes: 1