Ruby XML parser



below is a XML code snippet



<testcase name="T.3.03.02">
<cmd>CMD_EXPORT_RAM_KEY</cmd>
<sreg_pre>40</sreg_pre>
<sreg_pre_bitmask>ff</sreg_pre_bitmask>
<sreg_post>40</sreg_post>
<sreg_post_bitmask>ff</sreg_post_bitmask>
<erc>ERC_NO_ERROR</erc>
<testvector>
<parameter name="UID" type="info">000000000000000000000000000002</parameter>
<parameter name="UID'" type="info">000000000000000000000000000002</parameter>
<parameter name="KeyId" type="info">0e</parameter>
<parameter name="Key" type="info">0f0e0d0c0b0a09080706050403020100</parameter>
<parameter name="AuthId" type="info">00</parameter>
<parameter name="KeyAuth" type="info">2b7e151628aed2a6abf7158809cf4f3c</parameter>
<parameter name="Old counter value of updated key slot" type="info">0000000</parameter>
<parameter name="New counter value C'" type="info">0000000</parameter>
<parameter name="Protection flags F'" type="info">00</parameter>
<parameter name="M1" type="output">000000000000000000000000000002e0</parameter>
<parameter name="M2" type="output">152876f29dc7ca8d18e38d70374492b05d908c8c584a0409849a553c75254def</parameter>
<parameter name="M3" type="output">bc6e79bc4458339174fc80fb08b83188</parameter>
<parameter name="M4" type="output">000000000000000000000000000002e07783b86ae87b87e3ca12809c2df75fae</parameter>
<parameter name="M5" type="output">c8fcc8859c69c8bd840ce8e24c5114e9</parameter>
</testvector>
<precondition>RAM_KEY_PLAIN = 1; RAM_KEY_EMPTY = 0</precondition>
<description>Export plain RAM_KEY with external debugger attached; Note: The security flags SECURE_BOOT_PROTECTION and DEBUGGER_PROTECTION of the key SECRET_KEY are inherited from MASTER_ECU_KEY.</description>
</testcase>


Now I want to access all "parameter name="Key" type="info" values. This is not the problem, but what I don't get is to access these informations conditionally. That means I want ONLY get the "parameter name="Key" type="info"-values if the condition < cmd > CMD_EXPORT_RAM_KEY(second line in XML) is valid. In this xml file there are also other commands (< cmd > lines) also with the Key parameter, but in these cases I don't want to get the key-values.


I didn't get it running :-( some ideas?


best regards : S


No comments:

Post a Comment