XML in NED of Omnet++(1)

XML in NED of Omnet++

The following example declares an xml parameter, and assigns an XML file to it:

simple TrafGen {

    parameters:

        xml profile;

    gates:

        output out;

}

module Node {

    submodules:

        trafGen1 : TrafGen {

            profile = xmldoc("data.xml");

        }

        ...

}

It is also possible to assign an XML element within a file to the parameter:

module Node {

    submodules:

        trafGen1 : TrafGen {

            profile = xmldoc("all.xml", "profile[@id='gen1']");

        }

        trafGen2 : TrafGen {

            profile = xmldoc("all.xml", "profile[@id='gen2']");

        }

}

<?xml>

<profile id="gen1">

  <element>3</element>

  <element>5</element>

</profile>

<profile id="ge21">

  <element>9</element>

</profile>

原文地址:https://www.cnblogs.com/CUCmehp/p/1551473.html