Intelligent XML processing?
Posted: Fri Mar 18, 2005 4:30 am
This question is in regard to replace filters, but is generalizable for other types of XML-based operations.
Is it possible to process XML data in such a way that all data within the boundaries of tag expressions and processing instructions, e.g., <tag attribute="foo"> is skipped, and only the PCDATA wrapped within tags is matched? The restrict filter seems to be not quite intelligent enough to perform this sort of operation (it may be possible to do this with a regex expression, but I cannot figure out how to write the expression properly).
Example:
Let's say I wanted to find the quote character and replace it with a tilde (but only in PCDATA):
Input:
Output:
Is it possible to process XML data in such a way that all data within the boundaries of tag expressions and processing instructions, e.g., <tag attribute="foo"> is skipped, and only the PCDATA wrapped within tags is matched? The restrict filter seems to be not quite intelligent enough to perform this sort of operation (it may be possible to do this with a regex expression, but I cannot figure out how to write the expression properly).
Example:
Let's say I wanted to find the quote character and replace it with a tilde (but only in PCDATA):
Input:
Code: Select all
<tag1 attribute1="foo" attribute2="bar">Hello<phrase attribute="planet">"World!"<?proc: "foo"?></phrase></tag1>
Code: Select all
<tag1 attribute1="foo" attribute2="bar">Hello<phrase attribute="planet">~World!~<?proc: "foo"?></phrase></tag1>