XML Node

Discuss RoboTask here
Post Reply
Rukbunker
Posts: 194
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

XML Node

Post by Rukbunker »

Hey Oleg,

I'm struggeling with this for a long time and I really need your help. I'm missing things, I guess. Now suffering from tunnelvision!
I have the following XML file:

<?xml version="1.0" encoding="UTF-8"?>
<NisPodcastExport>
<Id>778D7A65B950F30DC12589DA00170047<Id>
<Published>True<Published>
<Author>Name of the host</Author>
<Category>DIF1</Category>
<Headline>HeadlineTitleHere</Headline>
<Body><![CDATA[<p>Description for the website</p>

<p><strong>Automatisch?</strong></p>

<p>Wil je voortaan elke ochtend deze podcast automatisch ontvangen? Plak dan&nbsp;<a href="https://script.dummydomain.nl/feed/podcast.xml" target="_blank">deze&nbsp;link</a>
&nbsp;(https://script.dummydomain.nl/feed/podcast.xml) in je favoriete podcastprogramma of -app. Bij Apple- en Google-podcast: zoek op "dummycompany".&nbsp;&nbsp;
</p>
]]></Body>
<Keywords></Keywords>
<Publication display="true">2023-06-26T06:11:14+02:00</Publication>
<Archive></Archive>
<Picture sourceId="A83D01B3C58FFB40C1258330002D318B" published="True">
<Filename>DEFAULT_PODCAST_A83D01B3C58FFB40C1258330002D318B.jpg</Filename>
<Still>DEFAULT_PODCAST_thumb_A83D01B3C58FFB40C1258330002D318B.jpg</Still>
<Title>DJ1 en DJ2 praten je bij</Title>
<Description>DJ1 en DJ2 praten je bij</Description>
<Keywords></Keywords>
<Rights></Rights>
<internal>0</internal>
</Picture>
<Audio sourceId="8D47AD2A37C6A6E3C12589DA001BEA2E" published="True">
<Filename>1017224.mp3</Filename>
<Still>audiostill.jpg</Still>
<Title>DJ1 en DJ2 praten je bij</Title>
<Description>DJ1 en DJ2 praten je bij</Description>
<Keywords></Keywords>
<Rights></Rights>
<internal>0</internal>
</Audio>
</NisPodcastExport>
What I want is relatively simple: I want to extract the values between the nodes, in bold text. I've tried already a lot of things, but no output what so ever. What is your advise?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: XML Node

Post by Oleg »

This is wrong XML file.
I see at least two errors
<Id>778D7A65B950F30DC12589DA00170047</Id>
<Published>True</Published>
It can not be processed as XML
Where did you get this text? If the text must have correct XML format then this is simple job
Look at my example below (I have corrected your "XML" in the task).
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1367"
Hide=INTEGER|0
ID=INTEGER|481232199
LogOnAsUser=INTEGER|1
Name=STRING|"Parse XML"
OnErrorTaskID=INTEGER|1879502808
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""xmlText"" with value ""<?xml version=""1.0"" encoding=""UTF-8""?>"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"xmlText"
expand=STRING|"0"
linecount=STRING|"36"
varname=STRING|"xmlText"
varvalue=STRING|"<?xml version=""1.0"" encoding=""UTF-8""?>"
varvalue00000001=STRING|"<NisPodcastExport>"
varvalue00000002=STRING|"	<Id>778D7A65B950F30DC12589DA00170047</Id>"
varvalue00000003=STRING|"	<Published>True</Published>"
varvalue00000004=STRING|"	<Author>Name of the host</Author>"
varvalue00000005=STRING|"	<Category>DIF1</Category>"
varvalue00000006=STRING|"	<Headline>HeadlineTitleHere</Headline>"
varvalue00000007=STRING|"	<Body><![CDATA[<p>Description for the website</p>"
varvalue00000009=STRING|"<p><strong>Automatisch?</strong></p>"
varvalue0000000B=STRING|"<p>Wil je voortaan elke ochtend deze podcast automatisch ontvangen? Plak dan&nbsp;<a href=""https://script.dummydomain.nl/feed/podcast.xml"" target=""_blank"">deze&nbsp;link</a>"
varvalue0000000C=STRING|"&nbsp;(https://script.dummydomain.nl/feed/podcast.xml) in je favoriete podcastprogramma of -app. Bij Apple- en Google-podcast: zoek op ""dummycompany"".&nbsp;&nbsp;</p>"
varvalue0000000D=STRING|"]]></Body>"
varvalue0000000E=STRING|"	<Keywords/>"
varvalue0000000F=STRING|"	<Publication display=""true"">2023-06-26T06:11:14+02:00</Publication>"
varvalue00000010=STRING|"	<Archive/>"
varvalue00000011=STRING|"	<Picture sourceId=""A83D01B3C58FFB40C1258330002D318B"" published=""True"">"
varvalue00000012=STRING|"		<Filename>DEFAULT_PODCAST_A83D01B3C58FFB40C1258330002D318B.jpg</Filename>"
varvalue00000013=STRING|"		<Still>DEFAULT_PODCAST_thumb_A83D01B3C58FFB40C1258330002D318B.jpg</Still>"
varvalue00000014=STRING|"		<Title>DJ1 en DJ2 praten je bij</Title>"
varvalue00000015=STRING|"		<Description>DJ1 en DJ2 praten je bij</Description>"
varvalue00000016=STRING|"		<Keywords/>"
varvalue00000017=STRING|"		<Rights/>"
varvalue00000018=STRING|"		<internal>0</internal>"
varvalue00000019=STRING|"	</Picture>"
varvalue0000001A=STRING|"	<Audio sourceId=""8D47AD2A37C6A6E3C12589DA001BEA2E"" published=""True"">"
varvalue0000001B=STRING|"		<Filename>1017224.mp3</Filename>"
varvalue0000001C=STRING|"		<Still>audiostill.jpg</Still>"
varvalue0000001D=STRING|"		<Title>DJ1 en DJ2 praten je bij</Title>"
varvalue0000001E=STRING|"		<Description>DJ1 en DJ2 praten je bij</Description>"
varvalue0000001F=STRING|"		<Keywords/>"
varvalue00000020=STRING|"		<Rights/>"
varvalue00000021=STRING|"		<internal>0</internal>"
varvalue00000022=STRING|"	</Audio>"
varvalue00000023=STRING|"</NisPodcastExport>"

[Actions\Action2]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"author"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Author"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"author"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action3\Params]
_rt_variables_produced=STRING|"category"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Category"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"category"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action4\Params]
_rt_variables_produced=STRING|"headline"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Headline"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"headline"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action5\Params]
_rt_variables_produced=STRING|"body"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Body"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"body"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action6\Params]
_rt_variables_produced=STRING|"Title"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Picture\Title"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"Title"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action7\Params]
_rt_variables_produced=STRING|"Description"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Picture\Description"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"Description"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action8]
ActionID=STRING|"A_XML_GETNODE"
Enabled=INTEGER|-1
Name=STRING|"XML Get Single Node"
Params=FOLDER

[Actions\Action8\Params]
_rt_variables_produced=STRING|"Filename"
attcount=STRING|"0"
foundresult=STRING|"0"
foundresultvariable=STRING|"f"
loadfile=STRING|"0"
ordernum=STRING|"0"
path=STRING|"\*\Audio\Filename"
raiseerror=STRING|"1"
savechildcount=STRING|"0"
savedepth=STRING|"0"
savenodename=STRING|"0"
savepath=STRING|"0"
savetext=STRING|"1"
savexml=STRING|"0"
textvar=STRING|"Filename"
xml00000000=STRING|"{xmlText}"
xmlcount=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|-1
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action9\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"Author: {author}"
line00000001=STRING|"Category: {category}"
line00000002=STRING|"Headline: {headline}"
line00000003=STRING|"Title: {Title}"
line00000004=STRING|"FileName: {Filename}"
line00000006=STRING|"Body:"
line00000007=STRING|"{body}"
line00000008=STRING|"--------"
linecount=STRING|"9"
timeout=STRING|"10"

Oleg Yershov
Rukbunker
Posts: 194
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: XML Node

Post by Rukbunker »

Oleg wrote: Thu Jul 06, 2023 2:45 pm This is wrong XML file.
I see at least two errors
<Id>778D7A65B950F30DC12589DA00170047</Id>
<Published>True</Published>
Correct, I've noticed that after pasting as well.

Thanks for this heads-up, this really pushes me into the right direction!
Post Reply