Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active June 17, 2022 16:41
Show Gist options
  • Select an option

  • Save steveosoule/8375e6188e927d8a0c32dc3bb71f3cbb to your computer and use it in GitHub Desktop.

Select an option

Save steveosoule/8375e6188e927d8a0c32dc3bb71f3cbb to your computer and use it in GitHub Desktop.
Miva - MVT Parse XML Example
<mvt:capture variable="l.xml:string">
<?xml version="1.0" encoding="UTF-8"?>
<codes>
<code>ABC-123-DEF-456</code>
<code>XYZ-987-TUV-000</code>
</codes>
</mvt:capture>
<mvt:assign name="l.xml:xml_parse_var_result" value="xml_parse_var( l.xml:string, l.xml:var )" />
<mvt:if expr="miva_array_elements( l.xml:var:codes:tags:code )">
<mvt:assign name="l.xml:first_code_tag" value="l.xml:var:codes:tags:code[1]" />
</mvt:if>
<mvt:if expr="l.xml:first_code_tag:value">
The `code` is: <mvt:eval expr="l.xml:first_code_tag:value" />
</mvt:if>
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.xml ), ',', asciichar( 10 ) )" />
<pre>
@@l.xml
&mvt:global:mvt_debug;
</pre>
The `code` is: ABC-123-DEF-456
@@l.xml
:first_code_tag:lineno=1
:first_code_tag:name=code
:first_code_tag:offset=47
:first_code_tag:value=ABC-123-DEF-456
:string=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0D%3Ccodes%3E%0D%3Ccode%3EABC-123-DEF-456%3C%2Fcode%3E%0D%3Ccode%3EXYZ-987-TUV-000%3C%2Fcode%3E%0D%3C%2Fcodes%3E%0D
:var:codes:children[1]:lineno=1
:var:codes:children[1]:name=code
:var:codes:children[1]:offset=47
:var:codes:children[1]:value=ABC-123-DEF-456
:var:codes:children[2]:lineno=1
:var:codes:children[2]:name=code
:var:codes:children[2]:offset=76
:var:codes:children[2]:value=XYZ-987-TUV-000
:var:codes:lineno=1
:var:codes:name=codes
:var:codes:offset=39
:var:codes:tags:code[1]:lineno=1
:var:codes:tags:code[1]:name=code
:var:codes:tags:code[1]:offset=47
:var:codes:tags:code[1]:value=ABC-123-DEF-456
:var:codes:tags:code[2]:lineno=1
:var:codes:tags:code[2]:name=code
:var:codes:tags:code[2]:offset=76
:var:codes:tags:code[2]:value=XYZ-987-TUV-000
:var:codes:value=%0D
:xml_parse_var_result=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment