Parse XML [Solved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kiffi
Addict
Addict
Posts: 1510
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Parse XML [Solved]

Post by Kiffi »

HeX0R wrote:Of course you could do an ExtractXMLStructure
You are right about that. I was referring to the complete XML.

Greetings ... Peter
Hygge
mocitymm
User
User
Posts: 37
Joined: Wed Feb 08, 2017 6:56 pm

Re: Parse XML [Solved]

Post by mocitymm »

After it woke me up around 2am in morning (obviously it was on my mind), I dropped the 'ParseXML' from the code provided by Kiffi and it works for what I need.

Thank you once again Kiffi.

Now on to being woke up at 1am to resolve loading large log file into Scintilla...

-M

Code: Select all

Structure sSubAgent
  Name.s
  Version.s
  Path.s  
EndStructure

Structure sSubAgents
  List SubAgent.sSubAgent()
EndStructure

Structure sClientConfig
  SubAgents.sSubAgents
EndStructure

LoadXML(0, "subagents.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()\Version = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Version"))
      ClientConfig\SubAgents\SubAgent()\Path    = GetXMLNodeText(XMLNodeFromPath(SubAgentNode, "Path"))      
     
      SubAgentNode = NextXMLNode(SubAgentNode)
     
    Wend
   
    FreeXML(0)   
    
   
    ForEach ClientConfig\SubAgents\SubAgent()
      
      Name.s = ClientConfig\SubAgents\SubAgent()\Name
      Version.s = ClientConfig\SubAgents\SubAgent()\Version
      Path.s = ClientConfig\SubAgents\SubAgent()\Path
      
      AddGadgetItem(LIcons_Agents, -1, Name.s + Chr(10) + Version.s + Chr(10) + Path.s)      
     
    Next
   
  Else
    Debug "!XMLStatus()"
  EndIf

Post Reply