Extracting all values, all text and all nodes with only wildcards
Posted: Sun Sep 22, 2019 2:20 am
Hi, questions: I have a 400MB xml and I need to extract all values, all text and all nodes from it in blocks and as efficiently possible. Here is a example of my xml tags:
What I need is nodes, values and text from every block, IMPORTANT: I do not know how many blocks, how many somethings and how many inner blocks are in the code and I do not know the names either, everything need to be extracted with only wildcards. here is the code I have up to this point ( obviously is not perfect) pleas help
the answer I am looking for is the next one:
the "child::*[.]" code is working nicely but the "*/@*[3]" is not I do not know how to use a wildcard instead of a 3 and I can not repeat the code from 1 to 100 there must be a better way. I have also tried the "//*" but I just cant make it work right... Any help will be appreciated, thank you all.
Code: Select all
<Big report>
<block something1="A" something2="B" something3="C" something4="D" something5="E"/>
<inner block>F</inner block>
<inner block>G</inner block>
<inner block>"H"</inner block>
<inner block>
<inner inner block something1="I" something2="J" something3="K"/>
</inner block>
</block>
<block something1="L" something2="M" something3="N" something4="O" something5="P"/>
<inner block>"Q"</inner block>
<inner block>
<inner inner block something1="R" something2="S" something3="T"/>
</inner block>
</block>
<something else>
</something else>
<Big report>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="Big report/block">
<xsl:value-of select="*/@*[3]"/>
<xsl:value-of select="child::*[.]"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Code: Select all
ABCDEFGHIJK
LMNOPQRST