Thema: xml read

Einzelnen Beitrag anzeigen

value is NULL

Registriert seit: 10. Sep 2010
249 Beiträge
 
#1

xml read

  Alt 11. Jan 2011, 08:36
Hi Delphianer

habe ein, ich glaube, kleines problem, komme jedoch nicht auf die Lösung.

ich habe folgendes XML:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<world localsitename="TEST-ENVIROMENT" localdomainname="TEST">
   <domain domainname="TEST">
      <site sitename="TEST-ENVIROMENT">
         <sitedatastore>
            <filestore servername="TEST-ENVIROMENT">
               <localpath>D:\</localpath>
               <networkshare>\\TEST-ENVIROMENT\vdata$</networkshare>
               <url>http://TEST-ENVIROMENT/sitedata</url>
               <maxusedspace />
               <minfreespace>2500</minfreespace>
            </filestore>
            <database>
               <dbtype>MSSQL</dbtype>
               <servername>TEST-ENVIROMENT</servername>
               <dbuser />
               <dbpwd />
               <dbname>data</dbname>
               <odbcdsn>data</odbcdsn>
               <timeout login="20" />
               <param id="UID" />
               <param id="PWD" />
               <param id="DSN">data</param>
               <param id="DRIVER">SQL Server</param>
               <param id="Server">TEST-ENVIROMENT</param>
               <param id="Database">data</param>
            </database>
         </sitedatastore>
         <mediaserver servername="TEST-ENVIROMENT" serverindex="1">
            <serialnumber>TEST-ENVIROMENT</serialnumber>
            <datastore>
               <localpath>D:\</localpath>
               <networkshare>\\TEST-ENVIROMENT\data$</networkshare>
            </datastore>
            <module_list>
               <module servername="TEST-ENVIROMENT" type="msgmgr" moduleindex="0" />
               <module servername="TEST-ENVIROMENT" type="Mgr" moduleindex="101" />
               <module subtype="log" servername="TEST-ENVIROMENT" type="log" moduleindex="104" />
               <module subtype="main" servername="TEST-ENVIROMENT" type="WebServer" moduleindex="110" />
               <module subtype="timesync" servername="TEST-ENVIROMENT" type="system" moduleindex="200" />
               <module subtype="hilowstat" servername="TEST-ENVIROMENT" type="system" moduleindex="201" />
               <module subtype="archiv" servername="TEST-ENVIROMENT" type="system" moduleindex="600" />
            </module_list>
         </mediaserver>
         <module subtype="archiv" servername="TEST-ENVIROMENT" type="system" moduleindex="600">
            <config>
               <exepath>C:\hilowstat.exe</exepath>
               <statusinterface>file:hilowstat.xml</statusinterface>
               <xmlpath>C:\test.xml</xmlpath>
               <parmconfigpath>C:\config.xml</parmconfigpath>
            </config>
         </module>
         <module servername="TEST-ENVIROMENT" type="msgmgr" moduleindex="0">
            <config>
               <exepath>C:\msgmgr.exe</exepath>
               <xmlpath>C:\msgmgr.xml</xmlpath>
               <parmconfigpath>C:\msgmgr_config.xml</parmconfigpath>
            </config>
         </module>
         <module subtype="timesync" servername="TEST-ENVIROMENT" type="system" moduleindex="200">
            <config>
               <exepath>C:\timesync.exe</exepath>
               <xmlpath>C:\timesync.xml</xmlpath>
               <statusinterface>http</statusinterface>
            </config>
         </module>
         <module subtype="hilowstat" servername="TEST-ENVIROMENT" type="system" moduleindex="201">
            <config>
               <exepath>C:\hilowstat.exe</exepath>
               <statusinterface>file:hilowstat.xml</statusinterface>
            </config>
         </module>
         <module servername="TEST-ENVIROMENT" serverindex="1" type="Mgr" moduleindex="101">
            <config>
               <exepath>C:\accmgr.exe</exepath>
               <statusinterface>http</statusinterface>
               <rpsmgr>
                  <rpslist>
                     <rps moduleindex="102" />
                  </rpslist>
                  <intervalcheckrpsconnection>1000</intervalcheckrpsconnection>
                  <autostartrps>1</autostartrps>
               </rpsmgr>
               <accdevmgr>
                  <devlist>
                     <accdev accdevindex="1">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="2">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="3">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="4">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="5">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="6">
                        <call controllingresource="channel" />
                     </accdev>
                     <accdev accdevindex="7">
                        <call controllingresource="tonedetector" />
                     </accdev>
                     <accdev accdevindex="8">
                        <call controllingresource="tonedetector" />
                     </accdev>
                  </devlist>
               </accdevmgr>
            </config>
         </module>
      </tsite>
   </domain>
</voxctworld>
ich lese mir mit folgendem Code ein Wieviele accdevindexes es gibt:

Delphi-Quellcode:
var
  ctcfg : IXMLDocument;
  ctcfgnode : IXMLNode;
  i : integer;

begin
  try
      i := 0;
      if not fileexists('C:\ctcfg.xml') then raise Exception.Create('ctcfg not found!');
      debug('Reading ctcfg...');
      CoInitialize(nil);
      ctcfg := LoadXMLDocument('C:\ctcfg.xml');
      ctcfgnode := ctcfg.DocumentElement.ChildNodes.First.ChildNodes.First.ChildNodes.FindNode('module').NextSibling.NextSibling.NextSibling.NextSibling.ChildNodes.FindNode('config').ChildNodes.FindNode('accdevmgr').ChildNodes.FindNode('devlist').ChildNodes.First;
      while not (ctcfgnode = nil) do begin
         i := i + 1;
         ctcfgnode := ctcfgnode.NextSibling;
      end;
      debug(inttostr(i) + ' Channels found!');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
das funzt ja auch prima ABER: ich möchte mir noch zusätzlich 2 zähler setzen, und zwar möchte ich zählen wieviele davon <call controllingresource="tonedetector" />
und wieviel <call controllingresource="channel" /> beinhalten.

hat jemand eine Idee?!

Vielen Dank schon mal

LG
  Mit Zitat antworten Zitat