0

I need to convert the xml output to a tabular format output. The issue is I don't know how to use xml parser in c if that is the only solution. I think there could be some other easier way as the format below is fixed.

I hope anyone of you could help me in solving this issue with the pseudo code or a quick way to use xml parser in c.

XML output
INPUT:
<nvme-subsystem-host-get-iter/>

OUTPUT:
<results status="passed">
    <attributes-list>
            <nvme-target-subsystem-host-info>
                    <host-nqn>nqn.2014-08.org.nvmexpress:nvmf:uuid:ef938fb1-1f35-421a-b31c-109014440371</host-nqn>
                    <io-queue-count>4</io-queue-count>
                    <io-queue-depth>18</io-queue-depth>
                    <subsystem>s1</subsystem>
                    <subsystem-uuid>ffede062-f762-11e7-ac91-00a098a3af76</subsystem-uuid>
                    <vserver>nv1</vserver>
                    <vserver-uuid>445abdde-f066-11e7-8053-00a098a3af76</vserver-uuid>
            </nvme-target-subsystem-host-info>
            <nvme-target-subsystem-host-info>
                    <host-nqn>nqn.2014-08.org.nvmexpress:nvmf:uuid:ef938fb1-1f35-421a-b31c-109014440371</host-nqn>
                    <io-queue-count>4</io-queue-count>
                    <io-queue-depth>18</io-queue-depth>
                    <subsystem>s2</subsystem>
                    <subsystem-uuid>98685d6c-f1d9-11e7-a0df-00a098a153c7</subsystem-uuid>
                    <vserver>nv1</vserver>
                    <vserver-uuid>445abdde-f066-11e7-8053-00a098a3af76</vserver-uuid>
            </nvme-target-subsystem-host-info>
            <nvme-target-subsystem-host-info>
                    <host-nqn>nqn.2014-08.org.nvmexpress:nvmf:uuid:6cfd4ef9-72f0-4ed1-9e96-45557d28462f</host-nqn>
                    <io-queue-count>4</io-queue-count>
                    <io-queue-depth>18</io-queue-depth>
                    <subsystem>s3</subsystem>
                    <subsystem-uuid>98b0643c-f1d9-11e7-a0df-00a098a153c7</subsystem-uuid>
                    <vserver>nv1</vserver>
                    <vserver-uuid>445abdde-f066-11e7-8053-00a098a3af76</vserver-uuid>
            </nvme-target-subsystem-host-info>
    </attributes-list>
    <num-records>3</num-records>

Tabular Output
Vserver Subsystem Host NQN
------- --------- ----------------------------------------------------------
nv1     s1         nqn.2014-08.org.nvmexpress:nvmf:uuid:ef938fb1-1f35-421a-b31c-109014440371
        s2         nqn.2014-08.org.nvmexpress:nvmf:uuid:ef938fb1-1f35-421a-b31c-10901444037
.
. 
Arjun G S
  • 23
  • 13
  • Naturally, this can be done via XSLT transformation. Do you really need to implement XML parsing/transforming manually in C? – Yury Schkatula Feb 14 '18 at 10:04
  • There are 2 possibilities: 1. you google "simple xml reader c", find some library and use that, 2. You parse the XML file yourself which isn't very diffiucult as the XML format you want to use is fixed. – Jabberwocky Feb 14 '18 at 10:08

0 Answers0