Need Help Getting Values from XML Text Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Need Help Getting Values from XML Text

Post by Mprobiz3 » 29 Jul 2020, 08:58

The Following Bold Text Or words with is what im needing to get from Clipboard, I have XML files that the bold data is always changing. I am needing to get this information and move to single doc or copy so i can paste to email.

Code: Select all

<?xml version="1.0" encoding="US-ASCII"?>

-<CadData xmlns:xsd="http www.w3.org /2001/XMLSchema"  Broken Link for safety xmlns:xsi="http www.w3.org /2001/XMLSchema-instance">  Broken Link for safety


-<EmsIncidentCollection>


-<EmsIncident>

<AgencyId>[size=150][b]087037F[/b][/size]</AgencyId>

<IncidentNumber>[b]2020-00000793[/b]</IncidentNumber>

<ResponseNumber>831</ResponseNumber>

<IncidentDateTime>[b]2020-07-28T11:35:29[/b]</IncidentDateTime>

<ControlledDateTime/>

<PsapCallDateTime>2020-07-28T11:35:29</PsapCallDateTime>

<DispatchNotifiedDateTime>2020-07-28T11:35:29</DispatchNotifiedDateTime>

<UnitNotifiedDispatchDateTime>2020-07-28T11:49:08</UnitNotifiedDispatchDateTime>

<UnitEnRouteDateTime/>

<UnitArrivedSceneDateTime/>

<DateTimeInitialResponderArrive>2020-07-28T12:30:21</DateTimeInitialResponderArrive>

<ArrivedPatientDateTime/>

<TransferPatientCareDateTime/>

<UnitLeftSceneDateTime/>

<PatientArrivedDestDateTime/>

<UnitBackServiceDateTime>2020-07-28T11:58:38</UnitBackServiceDateTime>

<RunReportNarrative>[b]NOTES[/b]</RunReportNarrative>

<Station>DFD STATION</Station>


-<Address>

<StreetAddress>[b]999 BROOKDALE DR[/b]</StreetAddress>

<City>[b]Dublin[/b]</City>

<State>[b]GA[/b]</State>

<ZipCode>[b]31021[/b]</ZipCode>

<Zone>DFD STATION</Zone>

<GpsLocationLatitude>[b]32.000050143[/b]</GpsLocationLatitude>

<GpsLocationLongitude>[b]-82.000527343[/b]</GpsLocationLongitude>

<CrossStreet>[b]PINEWOOD DR / BROOKDALE CT[/b]</CrossStreet>

</Address>


-<Unit>

<UnitNumber>DFD</UnitNumber>

<CallSign>DFD</CallSign>

<PrimaryRole>STATION</PrimaryRole>

<TypeOfServiceRequested>[b]FALL[/b]</TypeOfServiceRequested>

</Unit>

<UnitPersonnelCollection/>

</EmsIncident>
Attachments
FLOWMSP_202057dd_0757.xml
Copy of file with format
(1.42 KiB) Downloaded 137 times

User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Need Help Getting Values from XML Text  Topic is solved

Post by TheDewd » 29 Jul 2020, 09:52

Example showing how to read an XML file, and then parse the XML data to get values from specific tag names, and then display each value in separate message boxes or combine everything together and display in a single message box.

Reply if you need something more specific and I'll try to help modify this script to meet your requirements.

Code: Select all

#SingleInstance, Force ; Only allow one running instance of script at one time

FileRead, XMLData, FLOWMSP_202057dd_0757.xml ; Read XML file

; Parse XML file for specific tag values
RegExMatch(XMLData, "s)<AgencyId>(.*?)<\/AgencyId>", AgencyId)
RegExMatch(XMLData, "s)<IncidentNumber>(.*?)<\/IncidentNumber>", IncidentNumber)
RegExMatch(XMLData, "s)<IncidentDateTime>(.*?)<\/IncidentDateTime>", IncidentDateTime)
RegExMatch(XMLData, "s)<RunReportNarrative>(.*?)<\/RunReportNarrative>", RunReportNarrative)
RegExMatch(XMLData, "s)<StreetAddress>(.*?)<\/StreetAddress>", StreetAddress)
RegExMatch(XMLData, "s)<City>(.*?)<\/City>", City)
RegExMatch(XMLData, "s)<State>(.*?)<\/State>", State)
RegExMatch(XMLData, "s)<ZipCode>(.*?)<\/ZipCode>", ZipCode)
RegExMatch(XMLData, "s)<GpsLocationLatitude>(.*?)<\/GpsLocationLatitude>", GpsLocationLatitude)
RegExMatch(XMLData, "s)<GpsLocationLongitude>(.*?)<\/GpsLocationLongitude>", GpsLocationLongitude)
RegExMatch(XMLData, "s)<CrossStreet>(.*?)<\/CrossStreet>", CrossStreet)
RegExMatch(XMLData, "s)<TypeOfServiceRequested>(.*?)<\/TypeOfServiceRequested>", TypeOfServiceRequested)

; Display values in separate message boxes
MsgBox, % AgencyId1
MsgBox, % IncidentNumber1
MsgBox, % IncidentDateTime1
MsgBox, % RunReportNarrative1
MsgBox, % StreetAddress1
MsgBox, % City1
MsgBox, % State1
MsgBox, % ZipCode1
MsgBox, % GpsLocationLatitude1
MsgBox, % GpsLocationLongitude1
MsgBox, % CrossStreet1
MsgBox, % TypeOfServiceRequested1

AllInfo := "" ; Declare variable
AllInfo .= AgencyId1 "`n"
AllInfo .= IncidentNumber1 "`n"
AllInfo .= IncidentDateTime1 "`n"
AllInfo .= RunReportNarrative1 "`n"
AllInfo .= StreetAddress1 "`n"
AllInfo .= City1 "`n"
AllInfo .= State1 "`n"
AllInfo .= ZipCode1 "`n"
AllInfo .= GpsLocationLatitude1 "`n"
AllInfo .= GpsLocationLongitude1 "`n"
AllInfo .= CrossStreet1 "`n"
AllInfo .= TypeOfServiceRequested1

; Display values in single message box
MsgBox, % AllInfo

Clipboard := AllInfo ; Copy all data to clipboard

colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Need Help Getting Values from XML Text

Post by colt » 29 Jul 2020, 10:52

This is janky but gets the job done.

Code: Select all

fileRead xml,xmlSource.xml

boldArr := strSplit(xml,["[b]","[/b]"])
bolds := 
for index,entry in boldArr
{
	if(!mod(index,2))
	{
		bolds .= entry . "`n"
	}
}

clipboard := bolds

User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Need Help Getting Values from XML Text

Post by TheDewd » 29 Jul 2020, 11:01

colt wrote:
29 Jul 2020, 10:52
This is janky but gets the job done.
@colt, I don't think the actual XML data will contain the bold tags. This is just the attempted formatting he tried for this post, but when applying the code tag in a post if will ignore the formatting and just show "[ b ]" and "[ /b ]" instead of actually making the text bold.

colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Need Help Getting Values from XML Text

Post by colt » 29 Jul 2020, 12:32

@TheDewd gotcha, seemed too good to be true haha

Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: Need Help Getting Values from XML Text

Post by Mprobiz3 » 29 Jul 2020, 13:49

The following is completed code that works great Thank you for your help. hope it could help someone else.


Code: Select all

#SingleInstance, Force ; Only allow one running instance of script at one time
Move:
{
Sleep 100
Clipboard := ""
While (Clipboard != "")
	Sleep, 100

Sleep 1500
FileMove, E:\999999\*.xml, C:\FLOW MSP\FlowmspCad.xml
Sleep 1500

FileRead, XMLData, C:\FLOW MSP\FlowmspCad.xml ; Read XML file

; Parse XML file for specific tag values
RegExMatch(XMLData, "s)<AgencyId>(.*?)<\/AgencyId>", AgencyId)
RegExMatch(XMLData, "s)<IncidentNumber>(.*?)<\/IncidentNumber>", IncidentNumber)
RegExMatch(XMLData, "s)<IncidentDateTime>(.*?)<\/IncidentDateTime>", IncidentDateTime)
RegExMatch(XMLData, "s)<RunReportNarrative>(.*?)<\/RunReportNarrative>", RunReportNarrative)
RegExMatch(XMLData, "s)<StreetAddress>(.*?)<\/StreetAddress>", StreetAddress)
RegExMatch(XMLData, "s)<City>(.*?)<\/City>", City)
RegExMatch(XMLData, "s)<State>(.*?)<\/State>", State)
RegExMatch(XMLData, "s)<ZipCode>(.*?)<\/ZipCode>", ZipCode)
RegExMatch(XMLData, "s)<GpsLocationLatitude>(.*?)<\/GpsLocationLatitude>", GpsLocationLatitude)
RegExMatch(XMLData, "s)<GpsLocationLongitude>(.*?)<\/GpsLocationLongitude>", GpsLocationLongitude)
RegExMatch(XMLData, "s)<CrossStreet>(.*?)<\/CrossStreet>", CrossStreet)
RegExMatch(XMLData, "s)<TypeOfServiceRequested>(.*?)<\/TypeOfServiceRequested>", TypeOfServiceRequested)

AllInfo := "" ; Declare variable
AllInfo .= AgencyId1 "`n"
AllInfo .= IncidentNumber1 "`n"
AllInfo .= IncidentDateTime1 "`n"
AllInfo .= RunReportNarrative1 "`n"
AllInfo .= StreetAddress1 "`n"
AllInfo .= City1 "`n"
AllInfo .= State1 "`n"
AllInfo .= ZipCode1 "`n"
AllInfo .= GpsLocationLatitude1 "`n"
AllInfo .= GpsLocationLongitude1 "`n"
AllInfo .= CrossStreet1 "`n"
AllInfo .= TypeOfServiceRequested1

Clipboard := AllInfo ; Copy all data to clipboard
Sleep 1500
MailItem := ComObjCreate("Outlook.Application").CreateItem(0)
MailItem.Recipients.Add("[email protected]")
MailItem.Recipients.Add("[email protected]")
MailItem.Subject := "DUBLIN FIRE DISPATCH"
MailItem.body :=  Clipboard
Sleep 1000
MailItem.Send

FormatTime, TimeString, , yyyy'_'hhmmss
FileCopy, C:\FLOW MSP\FlowmspCad.xml, C:\FLOW MSP\OLD Calls\FLOWMSP_%TimeString%.xml
Sleep 2000
FileDelete, C:\FLOW MSP\FlowmspCad.xml
}
Goto, Move
Last edited by Mprobiz3 on 29 Jul 2020, 13:51, edited 1 time in total.

awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Need Help Getting Values from XML Text

Post by awel20 » 29 Jul 2020, 13:51

The following example is based on the example from the COM Object Reference topic found here: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77#p488
It shows how to load the XML from text and read a value.

Code: Select all

; COM Ojbect Reference: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77#p488

XMLText =
(
<?xml version="1.0" encoding="UTF-8"?>
<CadData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <EmsIncidentCollection>
      <EmsIncident>
         <AgencyId>087037F</AgencyId>
         <IncidentNumber>2020-00000796</IncidentNumber>
         <ResponseNumber>176</ResponseNumber>
         <IncidentDateTime>2020-07-29T02:50:19</IncidentDateTime>
         <ControlledDateTime />
         <PsapCallDateTime>2020-07-29T02:50:19</PsapCallDateTime>
         <DispatchNotifiedDateTime>2020-07-29T02:50:19</DispatchNotifiedDateTime>
         <UnitNotifiedDispatchDateTime>2020-07-29T02:52:40</UnitNotifiedDispatchDateTime>
         <UnitEnRouteDateTime />
         <UnitArrivedSceneDateTime />
         <DateTimeInitialResponderArrive />
         <ArrivedPatientDateTime />
         <TransferPatientCareDateTime />
         <UnitLeftSceneDateTime />
         <PatientArrivedDestDateTime />
         <UnitBackServiceDateTime />
         <RunReportNarrative>8772387739..OPER CHUCK
K/H PENDING</RunReportNarrative>
         <Station>DFD STATION</Station>
         <Address>
            <StreetAddress>606 SIMMONS ST</StreetAddress>
            <City>Dublin</City>
            <State>GA</State>
            <ZipCode>31021</ZipCode>
            <Zone>DFD STATION</Zone>
            <GpsLocationLatitude>32.518142829</GpsLocationLatitude>
            <GpsLocationLongitude>-82.914331758</GpsLocationLongitude>
            <CrossStreet>HAYES ST / PLUMMER ST</CrossStreet>
         </Address>
         <Unit>
            <UnitNumber>DFD-</UnitNumber>
            <CallSign>DFD-</CallSign>
            <PrimaryRole>STATION</PrimaryRole>
            <TypeOfServiceRequested>FIRE-ALARM</TypeOfServiceRequested>
         </Unit>
         <UnitPersonnelCollection />
      </EmsIncident>
   </EmsIncidentCollection>
</CadData>
)

XMLDoc := ComObjCreate("MSXML2.DOMDocument.6.0")
XMLDoc.async := false
XMLDoc.loadXML(XMLText)
XMLNode := XMLDoc.selectSingleNode("/CadData/EmsIncidentCollection/EmsIncident/AgencyId")
MsgBox % "> " XMLNode.nodeName "`n> " XMLNode.text
The following example uses the XML class by maestrith found here: https://www.autohotkey.com/boards/viewtopic.php?t=33114
It will load XML from a file and get a value. You will need to copy and paste the XML class into the script.

Code: Select all

XMLFilePath := A_ScriptDir "\FLOWMSP_202057dd_0757.xml"
XMLObj := new XML("Doc", XMLFilePath)
MsgBox % XMLObj.SSN("/CadData/EmsIncidentCollection/EmsIncident/AgencyId").Text

; Copy and paste the XML class here
; https://www.autohotkey.com/boards/viewtopic.php?t=33114

Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: Need Help Getting Values from XML Text

Post by Mprobiz3 » 30 Jul 2020, 08:01

This is Updated code with Kinks worked out, after i posted the other code I started having Clipboard Errors. So I tried a few things and found i did not need clipboard at all if all function are in script. Hope this code can help others in need.
Im not sure if extra unit Numbers work, I added them and have not tested yet.

Code: Select all

Move:
{
if FileExist("C:\CAD\Cad.xml")
Sleep 2500
FileRead, XMLData, C:\CAD\Cad.xml ; Read XML file
if !FileExist("C:\CAD\Cad.xml")
	Goto, Move

; Parse XML file for specific tag values
RegExMatch(XMLData, "s)<AgencyId>(.*?)<\/AgencyId>", AgencyId)
RegExMatch(XMLData, "s)<IncidentNumber>(.*?)<\/IncidentNumber>", IncidentNumber)
RegExMatch(XMLData, "s)<IncidentDateTime>(.*?)<\/IncidentDateTime>", IncidentDateTime)
RegExMatch(XMLData, "s)<RunReportNarrative>(.*?)<\/RunReportNarrative>", RunReportNarrative)
RegExMatch(XMLData, "s)<StreetAddress>(.*?)<\/StreetAddress>", StreetAddress)
RegExMatch(XMLData, "s)<City>(.*?)<\/City>", City)
RegExMatch(XMLData, "s)<State>(.*?)<\/State>", State)
RegExMatch(XMLData, "s)<ZipCode>(.*?)<\/ZipCode>", ZipCode)
RegExMatch(XMLData, "s)<GpsLocationLatitude>(.*?)<\/GpsLocationLatitude>", GpsLocationLatitude)
RegExMatch(XMLData, "s)<GpsLocationLongitude>(.*?)<\/GpsLocationLongitude>", GpsLocationLongitude)
RegExMatch(XMLData, "s)<CrossStreet>(.*?)<\/CrossStreet>", CrossStreet)
RegExMatch(XMLData, "s)<TypeOfServiceRequested>(.*?)<\/TypeOfServiceRequested>", TypeOfServiceRequested)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)
RegExMatch(XMLData, "s)<UnitNumber>(.*?)<\/UnitNumber>", UnitNumber)

AllInfo := "" ; Declare variable
AllInfo .= AgencyId1 "`n"
AllInfo .= TypeOfServiceRequested1
AllInfo .= IncidentNumber1 "`n"
AllInfo .= IncidentDateTime1 "`n"
AllInfo .= RunReportNarrative1 "`n"
AllInfo .= StreetAddress1 "`n"
AllInfo .= City1 "`n"
AllInfo .= State1 "`n"
AllInfo .= ZipCode1 "`n"
AllInfo .= GpsLocationLatitude1 "`n"
AllInfo .= GpsLocationLongitude1 "`n"
AllInfo .= CrossStreet1 "`n"
AllInfo .= UnitNumber1 "`n"
AllInfo .= UnitNumber2 "`n"
AllInfo .= UnitNumber3 "`n"
AllInfo .= UnitNumber4 "`n"
AllInfo .= UnitNumber5 "`n"
AllInfo .= UnitNumber6 "`n"

Sleep 1500
MailItem := ComObjCreate("Outlook.Application").CreateItem(0)
MailItem.Recipients.Add("[email protected]")
MailItem.Subject := "DISPATCH"
MailItem.body :=  AllInfo
Sleep 1000
MailItem.Send

Sleep 2000
FileDelete, C:\FLOW MSP\Cad.xml


}
Goto, Move

Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: Need Help Getting Values from XML Text

Post by Mprobiz3 » 30 Jul 2020, 08:04

colt wrote:
29 Jul 2020, 10:52
This is janky but gets the job done.

Code: Select all

fileRead xml,xmlSource.xml

boldArr := strSplit(xml,["[b]","[/b]"])
bolds := 
for index,entry in boldArr
{
	if(!mod(index,2))
	{
		bolds .= entry . "`n"
	}
}

clipboard := bolds
This was my first time trying to make Code Bold. It did not work. i was going to make it bold to stand out to everyone show there was a understanding of what i was needing to get from Xml.
Thank you for your help

Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: Need Help Getting Values from XML Text

Post by Mprobiz3 » 30 Jul 2020, 10:22

How would I add title to each value? Like "ID:" Before AgencyId or "Number:" Before Incident Number
TheDewd wrote:
29 Jul 2020, 09:52
Example showing how to read an XML file, and then parse the XML data to get values from specific tag names, and then display each value in separate message boxes or combine everything together and display in a single message box.

Reply if you need something more specific and I'll try to help modify this script to meet your requirements.

Code: Select all

#SingleInstance, Force ; Only allow one running instance of script at one time

FileRead, XMLData, FLOWMSP_202057dd_0757.xml ; Read XML file

; Parse XML file for specific tag values
RegExMatch(XMLData, "s)<AgencyId>(.*?)<\/AgencyId>", AgencyId)
RegExMatch(XMLData, "s)<IncidentNumber>(.*?)<\/IncidentNumber>", IncidentNumber)
RegExMatch(XMLData, "s)<IncidentDateTime>(.*?)<\/IncidentDateTime>", IncidentDateTime)
RegExMatch(XMLData, "s)<RunReportNarrative>(.*?)<\/RunReportNarrative>", RunReportNarrative)
RegExMatch(XMLData, "s)<StreetAddress>(.*?)<\/StreetAddress>", StreetAddress)
RegExMatch(XMLData, "s)<City>(.*?)<\/City>", City)
RegExMatch(XMLData, "s)<State>(.*?)<\/State>", State)
RegExMatch(XMLData, "s)<ZipCode>(.*?)<\/ZipCode>", ZipCode)
RegExMatch(XMLData, "s)<GpsLocationLatitude>(.*?)<\/GpsLocationLatitude>", GpsLocationLatitude)
RegExMatch(XMLData, "s)<GpsLocationLongitude>(.*?)<\/GpsLocationLongitude>", GpsLocationLongitude)
RegExMatch(XMLData, "s)<CrossStreet>(.*?)<\/CrossStreet>", CrossStreet)
RegExMatch(XMLData, "s)<TypeOfServiceRequested>(.*?)<\/TypeOfServiceRequested>", TypeOfServiceRequested)

; Display values in separate message boxes
MsgBox, % AgencyId1
MsgBox, % IncidentNumber1
MsgBox, % IncidentDateTime1
MsgBox, % RunReportNarrative1
MsgBox, % StreetAddress1
MsgBox, % City1
MsgBox, % State1
MsgBox, % ZipCode1
MsgBox, % GpsLocationLatitude1
MsgBox, % GpsLocationLongitude1
MsgBox, % CrossStreet1
MsgBox, % TypeOfServiceRequested1

AllInfo := "" ; Declare variable
AllInfo .= AgencyId1 "`n"
AllInfo .= IncidentNumber1 "`n"
AllInfo .= IncidentDateTime1 "`n"
AllInfo .= RunReportNarrative1 "`n"
AllInfo .= StreetAddress1 "`n"
AllInfo .= City1 "`n"
AllInfo .= State1 "`n"
AllInfo .= ZipCode1 "`n"
AllInfo .= GpsLocationLatitude1 "`n"
AllInfo .= GpsLocationLongitude1 "`n"
AllInfo .= CrossStreet1 "`n"
AllInfo .= TypeOfServiceRequested1

; Display values in single message box
MsgBox, % AllInfo

Clipboard := AllInfo ; Copy all data to clipboard

awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Need Help Getting Values from XML Text

Post by awel20 » 30 Jul 2020, 10:57

Code: Select all

XMLFilePath := A_ScriptDir "\FLOWMSP_202057dd_0757.xml"
FileRead, XMLText, % XMLFilePath
XMLDoc := ComObjCreate("MSXML2.DOMDocument.6.0")
XMLDoc.async := false
XMLDoc.loadXML(XMLText)
XPaths := [["ID", "/CadData/EmsIncidentCollection/EmsIncident/AgencyId"]
         , ["Number", "/CadData/EmsIncidentCollection/EmsIncident/IncidentNumber"]
         , ["Time", "/CadData/EmsIncidentCollection/EmsIncident/IncidentDateTime"]
         , ["Run Report Narrative", "/CadData/EmsIncidentCollection/EmsIncident/RunReportNarrative"]
         , ["Street Address", "/CadData/EmsIncidentCollection/EmsIncident/Address/StreetAddress"]
         , ["City", "/CadData/EmsIncidentCollection/EmsIncident/Address/City"]
         , ["State", "/CadData/EmsIncidentCollection/EmsIncident/Address/State"]
         , ["Zip Code", "/CadData/EmsIncidentCollection/EmsIncident/Address/ZipCode"]
         , ["Gps Location Latitude", "/CadData/EmsIncidentCollection/EmsIncident/Address/GpsLocationLatitude"]
         , ["Gps Location Longitude", "/CadData/EmsIncidentCollection/EmsIncident/Address/GpsLocationLongitude"]
         , ["Cross Street", "/CadData/EmsIncidentCollection/EmsIncident/Address/CrossStreet"]
         , ["Type Of Service Requested", "/CadData/EmsIncidentCollection/EmsIncident/Unit/TypeOfServiceRequested"]]

Info := ""
for i, Item in XPaths
{
    XMLNode := XMLDoc.selectSingleNode(Item.2)
    Info .= Item.1 ": " XMLNode.text "`r`n"
}
Info := RTrim(Info, "`r`n")
MsgBox % Info

awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Need Help Getting Values from XML Text

Post by awel20 » 30 Jul 2020, 11:02

Mprobiz3 wrote:
30 Jul 2020, 10:22
How would I add title to each value? Like "ID:" Before AgencyId or "Number:" Before Incident Number
You can add some text to this part:

Code: Select all

AllInfo .= "ID: " AgencyId1 "`n"
AllInfo .= "Type Of Service Requested: " TypeOfServiceRequested1
AllInfo .= "ID#: " IncidentNumber1 "`n"
AllInfo .= "Date and Time: " IncidentDateTime1 "`n"

Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: Need Help Getting Values from XML Text

Post by Mprobiz3 » 06 Aug 2020, 14:59

Thank you All for the help..
I am having more trouble. @TheDewd Your code works great, I am not however able to figure out how to get information that is different further down XML file. Example is below.

XML FILE
<?xml version="1.0" encoding="US-ASCII"?>

-<CadData xmlns:xsd="http www.w3.org /2001/XMLSchema" Broken Link for safety xmlns:xsi="http www.w3.org /2001/XMLSchema-instance"> Broken Link for safety


-<EmsIncidentCollection>


-<EmsIncident>

<AgencyId>087037F</AgencyId>

<IncidentNumber>2020-00000847</IncidentNumber>

<ResponseNumber>632</ResponseNumber>

<IncidentDateTime>2020-08-06T15:29:00</IncidentDateTime>

<ControlledDateTime/>

<PsapCallDateTime>2020-08-06T15:29:00</PsapCallDateTime>

<DispatchNotifiedDateTime>2020-08-06T15:29:00</DispatchNotifiedDateTime>

<UnitNotifiedDispatchDateTime>2020-08-06T15:30:40</UnitNotifiedDispatchDateTime>

<UnitEnRouteDateTime/>

<UnitArrivedSceneDateTime/>

<DateTimeInitialResponderArrive>2020-08-06T15:34:04</DateTimeInitialResponderArrive>

<ArrivedPatientDateTime/>

<TransferPatientCareDateTime/>

<UnitLeftSceneDateTime/>

<PatientArrivedDestDateTime/>

<UnitBackServiceDateTime>2020-08-06T15:33:44</UnitBackServiceDateTime>

<RunReportNarrative>FIRE AT THE LOCATION HAY FIELD ON FIRE SPREADING TO THE WOODS</RunReportNarrative>

<Station>RFD STATION 3</Station>


-<Address>

<StreetAddress>MARLEY CANNON RD / MADDOX ROYSTER RD</StreetAddress>

<StreetAddress2>s2 clr</StreetAddress2>

<City>Dublin</City>

<State>GA</State>

<ZipCode>31021</ZipCode>

<Zone>Dublin Auto Aid 1-3</Zone>

<GpsLocationLatitude>32.574382592</GpsLocationLatitude>

<GpsLocationLongitude>-82.993622823</GpsLocationLongitude>

</Address>


-<Unit>

<UnitNumber>DFD-</UnitNumber>

<CallSign>DFD-</CallSign>

<PrimaryRole>STATION</PrimaryRole>

<TypeOfServiceRequested>FIRE</TypeOfServiceRequested>

</Unit>

<UnitPersonnelCollection/>

</EmsIncident>


-<EmsIncident>

<AgencyId>087037F</AgencyId>

<IncidentNumber>2020-00000847</IncidentNumber>

<ResponseNumber>632</ResponseNumber>

<IncidentDateTime>2020-08-06T15:29:00</IncidentDateTime>

<ControlledDateTime/>

<PsapCallDateTime>2020-08-06T15:29:00</PsapCallDateTime>

<DispatchNotifiedDateTime>2020-08-06T15:29:00</DispatchNotifiedDateTime>

<UnitNotifiedDispatchDateTime>2020-08-06T15:33:41</UnitNotifiedDispatchDateTime>

<UnitEnRouteDateTime>2020-08-06T15:33:41</UnitEnRouteDateTime>

<UnitArrivedSceneDateTime/>

<DateTimeInitialResponderArrive>2020-08-06T15:34:04</DateTimeInitialResponderArrive>

<ArrivedPatientDateTime/>

<TransferPatientCareDateTime/>

<UnitLeftSceneDateTime/>

<PatientArrivedDestDateTime/>

<UnitBackServiceDateTime/>

<RunReportNarrative>FIRE AT THE LOCATION HAY FIELD ON FIRE SPREADING TO THE WOODS</RunReportNarrative>

<Station>RFD STATION 3</Station>


-<Address>

<StreetAddress>MARLEY CANNON RD / MADDOX ROYSTER RD</StreetAddress>

<StreetAddress2>s2 clr</StreetAddress2>

<City>Dublin</City>

<State>GA</State>

<ZipCode>31021</ZipCode>

<Zone>Dublin Auto Aid 1-3</Zone>

<GpsLocationLatitude>32.574382592</GpsLocationLatitude>

<GpsLocationLongitude>-82.993622823</GpsLocationLongitude>

</Address>


-<Unit>

<UnitNumber>E3</UnitNumber>

<CallSign>E3</CallSign>

<PrimaryRole>ENGINE</PrimaryRole>

<TypeOfServiceRequested>FIRE</TypeOfServiceRequested>

</Unit>


-<UnitPersonnelCollection>


-<UnitPersonnel>

<CrewMemberId>e3</CrewMemberId>

<CrewMemberRole>Primary</CrewMemberRole>

</UnitPersonnel>

</UnitPersonnelCollection>

</EmsIncident>

</EmsIncidentCollection>

</CadData>
I would like to get Second, Third Etc.. Units, Date and times.
I have researched, and tried different things to get it to populate extra info. If you could help i would greatly appreciate it.
Or if anyone else has knowledge with the same ReExMatch setup as @TheDewd

Post Reply

Return to “Ask for Help (v1)”