Kiffi wrote:You cannot use ExtractXMLStructure().
Instead, you must read the XML manually:
Code: Select all
EnableExplicit
Structure sSubAgent
Name.s
GUID.s
ProgId.s
Version.s
Build.s
Path.s
Is64bit.s
EndStructure
Structure sSubAgents
List SubAgent.sSubAgent()
EndStructure
Structure sClientConfig
SubAgents.sSubAgents
EndStructure
Define Xml.s
Xml = "<ClientConfig>" +
" <SubAgents>" +
" <SubAgent id='CTAGENT'>" +
" <Name>Altiris Client Task Agent</Name>" +
" <GUID>{A8508496-ECA5-9197-E985-93FC4DF2837F}</GUID>" +
" <ProgId>Altiris.ClientTaskAgent</ProgId>" +
" <Version>8.5.4235</Version>" +
" <Build>4235</Build>" +
" <Path>/opt/altiris/notification/ctagent</Path>" +
" <Is64bit>true</Is64bit>" +
" </SubAgent>" +
" <SubAgent id='CTSCHEDAGENT'>" +
" <Name>Altiris Client Task Scheduling Agent</Name>" +
" <GUID>{68566E79-E211-B6EB-BFF2-9BA54305970B}</GUID>" +
" <ProgId>Altiris.CTSchedulingAgent</ProgId>" +
" <Version>8.5.4235</Version>" +
" <Build>4235</Build>" +
" <Path>/opt/altiris/notification/ctagent</Path>" +
" <Is64bit>true</Is64bit>" +
" </SubAgent>" +
" <SubAgent id='CTBASEHANDLERS'>" +
" <Name>Altiris Base Task Handlers</Name>" +
" <GUID>{FFB63A97-35C8-1445-02B0-54034E45B091}</GUID>" +
" <ProgId>Altiris.BaseTaskHandlersAgent</ProgId>" +
" <Version>8.5.4235</Version>" +
" <Build>4235</Build>" +
" <Path>/opt/altiris/notification/basetasks</Path>" +
" <Is64bit>true</Is64bit>" +
" </SubAgent> " +
" </SubAgents>" +
"</ClientConfig>"
If ParseXML(0, xml)
If XMLStatus(0) = #PB_XML_Success
Define ClientConfig.sClientConfig
Define SubAgentNode = XMLNodeFromPath(MainXMLNode(0), "SubAgents/SubAgent")
While SubAgentNode
AddElement(ClientConfig\SubAgents\SubAgent())
ClientConfig\SubAgents\SubAgent()\Name = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Name"))
ClientConfig\SubAgents\SubAgent()\GUID = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "GUID"))
ClientConfig\SubAgents\SubAgent()\ProgId = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "ProgId"))
ClientConfig\SubAgents\SubAgent()\Version = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Version"))
ClientConfig\SubAgents\SubAgent()\Build = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Build"))
ClientConfig\SubAgents\SubAgent()\Path = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Path"))
ClientConfig\SubAgents\SubAgent()\Is64bit = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Is64bit"))
SubAgentNode = NextXMLNode(SubAgentNode)
Wend
FreeXML(0)
; Output:
ForEach ClientConfig\SubAgents\SubAgent()
Debug ClientConfig\SubAgents\SubAgent()\Name
Debug ClientConfig\SubAgents\SubAgent()\GUID
; and so on...
Next
Else
Debug "!XMLStatus()"
EndIf
Else
Debug "!ParseXML()"
EndIf
[/size]
P.S.: The question would have been resolved much faster if you had posted a piece
of your code and asked why it did not work.
Kiffi,
Thank you for the offer of help, the pointer on ExtractXMLStructure (is going to save me time and head banging, I appreciate it) however, your code won't work.
I am not writing the xml file only reading it, the xml file is an output of a service on the machine.
I can't change " to ' around SubAgent id='CTAGENT' (now if single quotes were native to the xml file, your code would work perfectly) otherwise, it generates the previous stated error:
'CTAGENT' or 'CTSCHEDAGENT' and or 'CTBASEHANDLERS' is not a valid operator
I appreciate the effort and when I said that I've tried numerous examples and included the link to the code that I tried, it was implied that this was the code that wasn't working.
I appreciate all the input from everyone. I will forego the conversion project since, I have it finished in Pascal which is working.
Regards,
-Mo