AnsweredAssumed Answered

XML Import Template Guidance (XLST)

Question asked by VelvetDoofus on Feb 5, 2019
Latest reply on Feb 9, 2019 by beverly

First and foremost, this is my first attempt at importing XML data into filmmaker. I am wanting to try out a simple xml file (attached below) to get the basics. the reason I chose this file is it has a small number of issues that don't seem to line up with the examples I've researched in this forum thus far.

 

1) When the "addr" tag is parsed, I'm not sure how to specify that I'm only interested in the first listing (or the one where addrtype="ipv4").

 

2) Second, I don't quiet know the best way to create the XLST when I am in need of two groups of nested data.

 

Ultimately, I'm trying to grab the following information for each host:

 

host/addr (where type=ipv4)

port/protocol

port/portid

port/state

service/name

 

Each individual record in the fm database will be as follows

 

host/addr (where type=ipv4), host/hostnames, port/protocol, port/portid, port/state, service/name

 

or based on the attached file

1.2.3.4, tcp, 80, open, http

1.2.3.4, tcp, 443, open, https

1.2.3.5, tcp, 80, open, http

etc..

 

I've also attached my head in the sand attempt at the xlst file.... I know its awful. Just trying to learn. I'm going to keep researching while this is posted. This is literally my first day looking at this, but eager to learn.

 

XML File

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE nmaprun>

<?xml-stylesheet href="file:///usr/local/bin/../share/nmap/nmap.xsl" type="text/xsl"?>

<!-- Nmap 7.31 scan initiated Tue Feb  5 14:46:38 2019 as: nmap -sS -oA allg 10.10.200.200-205 -->

<nmaprun scanner="nmap" args="123" start="1549395998" startstr="Tue Feb 2 14:46:38 2016" version="7.31" xmloutputversion="1.04">

<scaninfo type="syn" protocol="tcp" numservices="1000" services="1,3-4,6-7"/>

<debugging level="0"/>

<host starttime="1549395998" endtime="1549395998"><status state="up" reason="arp-response" reason_ttl="0"/>

<address addr="1.2.3.4" addrtype="ipv4"/>

<address addr="AB:AB:AB:AB:AB:AB" addrtype="mac"/>

<hostnames>

</hostnames>

<ports><extraports state="closed" count="995">

<extrareasons reason="resets" count="995"/>

</extraports>

<port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="http" method="table" conf="3"/></port>

<port protocol="tcp" portid="443"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="https" method="table" conf="3"/></port>

</ports>

<times srtt="2397" rttvar="475" to="100000"/>

</host>

<host starttime="1549395998" endtime="1549395998"><status state="up" reason="arp-response" reason_ttl="0"/>

<address addr="1.2.3.5" addrtype="ipv4"/>

<address addr="AC:AC:AC:AC:AC:AC" addrtype="mac" vendor="Yugo"/>

<hostnames>

</hostnames>

<ports><extraports state="closed" count="984">

<extrareasons reason="resets" count="984"/>

</extraports>

<port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="http" method="table" conf="3"/></port>

<port protocol="tcp" portid="139"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="netbios-ssn" method="table" conf="3"/></port>

<port protocol="tcp" portid="443"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="https" method="table" conf="3"/></port>

<port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="microsoft-ds" method="table" conf="3"/></port>

</ports>

<times srtt="4819" rttvar="606" to="100000"/>

</host>

<runstats><finished time="1549395998" timestr="Tue Feb 2 14:46:38 2016" elapsed="0.88" summary="Nmap done at Tue Feb  2 14:46:38 2016; 4 IP addresses (2 hosts up) scanned in 0.88 seconds" exit="success"/><hosts up="2" down="2" total="4"/>

</runstats>

</nmaprun>

 

XLST File (I know this is the worst ever - just a starting point)

 

<?xml version='1.0' encoding='UTF-8'?>   

<xsl:stylesheet version="1.0"  

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   

    <xsl:template match="/">   

        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">   

            <METADATA>     

                <FIELD NAME="address" TYPE="TEXT"/>    ???????      

                <FIELD NAME="port/protocol" TYPE="TEXT"/>    

                <FIELD NAME="port/portid" TYPE="TEXT"/> 

                <FIELD NAME="port/state" TYPE="TEXT"/> 

                <FIELD NAME="service/name" TYPE="TEXT"/> 

            </METADATA>   

            <RESULTSET>   

                <xsl:for-each select="/nmaprun/host"> 

                    <ROW>   

                        <COL><DATA><xsl:value-of select="address"/></DATA></COL> 

                    </ROW>  

                <xsl:for-each select="/nmaprun/host/port"> 

                    <ROW>   

                        <COL><DATA><xsl:value-of select="protocol"/></DATA></COL>

                        <COL><DATA><xsl:value-of select="portid"/></DATA></COL>

                        <COL><DATA><xsl:value-of select="service/name"/></DATA></COL>     

                    </ROW>   

                </xsl:for-each> 

            </RESULTSET>

        </FMPXMLRESULT>  

    </xsl:template>   

</xsl:stylesheet>  

 

VD - I'm a moron

Outcomes