Parsing XML in Flow Designer- Live Coding Happy Hour for 2020-04-17
hello and welcome to live code happy hour on this April 17th 2020 I'm here today with a brand-new first-time guest so let's go ahead and jump right into introductions with longtime guest check hey how you doing my name is Chuck Tomasi I'm a senior developer evangelist for ServiceNow been with the company since 2010 was customer for a couple of years before that I love doing things around custom applications integrations and just platform in general where I have fun awesome thanks Chuck and Craig hey I'm Craig step I'm a staff programmer at ServiceNow I've been here for six years and I handle cloud labs I don't know if you're familiar with that a lot of people on the internal side of ServiceNow know about it but if you ever taken any of our classes like acknowledged or maybe any online training or I started sable done a survey in person but not right now but you know what I think any of our training and getting there one of the instances where you can do the labs with the lab with the instructor that's that's what I do I'll handle the backend infrastructure for all of our training so that's me and generally have you you know nerd yeah Brett yeah Brad Tilton I'm a developer advocate with the developer program at ServiceNow I have been doing ServiceNow stuff since about 2008 and I've spent time as a customer partner trainer and now employee for a while awesome now I'm Andrew Barnes developer advocate in the platform business unit I specialize in creating custom applications integrations managing large scale development teams and moving their development artifacts through the pipeline super excited to have you guys here with us today will now do our traditional introduction of our beverage of choice today in the same order going back around my name is Chuck Tomasi senior development I'm having something we've never had on live coding happy hour before grapefruit juice hey pace yourself we're drinking them man you got a 30 in the afternoon man I really do have to pace myself plus you got to drive home right all the way upstairs yeah you know one-story house it's more dangerous that's right my beverage of choice at least today is the white claw hard seltzer and it's alright it's hard sales for water it's not too bad this is the Ruby grapefruit you give me crap about grapefruit what what do you have with your fancy New York shirt on today Brad oh we've got the New York release I've got my Kentucky Bourbon Barrel ale because out Seasons kind of over a stout season is never over yeah I have a very special beer today which is another your old Tuffy beer with with my universities you know nice Wolfpack logo on there oh yeah so I've not had this yet up I saw that they came out with this about a year ago and I hadn't had it it's a it's a New Belgium and I'm super excited to try it I've never had it but I've worked for the University for 20 years and I hope it's good I hope it's good so you work for the University what you do there so I talked computer science for a long time and then worked in the enterprise application systems running large-scale stuff and eventually that became ServiceNow became in my portfolio and then I specialized in that I see okay so the problem space today so the reason Craig's on it's because he has an interesting problem that he'd like to solve and we like to solve problems right so tell us about what what brought you on today okay so I again I don't know if everybody knows about some of my background personally I do quite a lot of podcasting a podcast with Chuck been doing that for what's him for 15 years and I started a challenge what was it about how many years we've been doing it 12 I think yeah so it was 7 7 8 years now we're in August I challenge podcasters to podcast once a day for 30 days you know and I joke about the challenges actually flipped because we got so many people participating went from doing the podcast every day to actually listening to them all because there's so many but fast forwarded my problem is I have an application I wrote it in PHP and everything I I've been a long time PHP developer for about well now 20 years now but I want to change the application I'm using to run on ServiceNow and what I do is I pull and I can go and share my screen and kind of give you a little rundown it's it's more of an aggregator right you're taking multiple RSS feeds and yes so mashing them into one right yeah so let me make sure my screen I'll show you we can't read that I know I'm getting ready to say man hold on hang on oh yeah we go is that well better we're going to work with Andrew and centering it can you bring it to the left side of your screen to the left yeah like that yeah all the way to the left you go that how's that all right so better yeah just stabilize in on what you want and then I'll adjust the rest okay so here's the sessions I'll start a session I'm this is I'm just saying right now I'm not running it but it's the dog days of Advent which I also do this in a around Christmastime so we're doing dog days of quarantine now yeah yeah now we're doing quarantine anyway there's a session and for each session I have feeds so under here is our Chucky Knotts podcast technirama and there's one of our friends wandering adventures and there's the feed URLs what I want to do is I want to take those feeds read them in it's an XML file and parse them out put them in the database and then what I will do on the other end I make this one big feed so I take all of the items that I pull in and I make one big feed so that's how everybody can listen to all the participants they just subscribe to that one RSS feed am I making sense so far yes okay bring in the XML parse it make records spit it out as one big XML that's exactly right so fast word now I was trying to take these feeds and pull them into flow and parse them and put them in my my items table okay probably most happen was I couldn't ever get the defeats to actually parse out so that's where I am now so let me pull this up this is the get the flow designer up and I'll give you a little rundown on this can you see that all right yep all right so here's my flow so I'll repeat every one hours in one second it'll go look up the feeds and for each feed it's going to run this action and the action would parse out the XML and then at that point I would populate my items table which you can see off its side but you can what are you thinking the output of read RSS feed is well it should be let me go over here and I'll pull it up so here's our read RSS feed and initially read the file so I use a connection to go out and request it and then under scripts I know I understand that this is a more it may make this but just over a little bit a little more real estate for the code editor there how's that that all right little work yeah we can see the code on the screen alright so here's the codes pull in the response body the response body response body oh I just sounded weird my head response body and I want to pipe it into the script and then I want to feed it out now I understand the code may not be right here because I've been I was experimenting with a lot of stuff so here is my problem I'm need to parse it out you know I was trying to use XML document to I don't know that that's right so here's somebody lip solution we have an XML parser in integration hub I was looking for that and I did not see it in my system ok so step one may be to activate the right plugins right okay well we can do that I can who's got a quick Doc's page up that tells us what we need to turn on for that one just so where is this a personal instance yeah it's my employee instance okay so yeah you're gonna need to drop in is maintained activate the Enterprise flow designer plug in I love my new skirt enterprise hearty Enterprise will cover everything so that's why I went to that so I don't have to look it up I say so it could be pro could be I I think it might be in the pro end but you guys will definitely get ok so I need to go hop in and and do that thing and if you'd like one of us to do that week yeah won't you go and do that yeah and while I'm waiting I will take a sip of my tasty beverage so yeah why don't y'all just talk through the the problem space a little more while I so Craig the general structure of the XML is pretty straightforward if I remember right there is it there's like an overall framework and then you've got some header information that tells you about the the site that the feed itself yeah and then there's a there's an array of is it items in there they don't weigh back because I haven't rolled my own RSS feed in a long long time we can I can pull up one of yours it I can pull up ours if you want to say okay so there's like a channel tag and a slash channel tag there's an item and a slash item but there's an array of those items in there and each item represents same episode for that shell that needs to be zoomed in yeah I'm trying to zoom in it's taking a minute do it so there's the channel okay so there's some header stuff that sets up namespace and what tags you can use mm-hmm so we've got channel down to where's the slash channels at the very end or is it at the end of a header I think it's at the end of this header well we get some HTML in there - what's up with that oh is that is that part of the post like the yeah chanted so yeah that would be the yeah that would be the post okay so yeah channels at the very end okay and then there's this array of items so we're wrapped or the channel is like a wrapper an inside of channel I'm sort of like dot walking it or reverse engineering structure in my head yeah let me go back on this channel so there's channel and then a node inside channel is items I thought yeah yep and there's a lot of the first one item tags I'm looking for the first one it should be right right there item and then there's and there's a there's a last episode right there okay and what information are you looking to get out of this everything um let's say I think that I was looking for there's a lot of tags you're gonna need a table with a lot of fields yeah and I'm eight I don't think I need everything but I do need a the title description the enclosure length type and Earl fede did I really need two feet and then I saved the the gooood which is identifier for the post in a link when the link goes tells your RSS feed reader to where the post is where the blog post is for it if you're just putting these into fields to generate XML out why not just save each item as like a bulk of XML just say here's what's between item and slash item save it we don't do we don't need to put just three fields around those do we well the only reason I was I was doing this as I can control how it looks when I dump it out so if you if you have a big block then I can't sort all of them by date got you yes you do need some pertinent information out of each yeah how are the identifying uniqueness cuz you're gonna be reading this once an hour you don't want to just keep adding records adding records adding records you want to be able to hmm that's what the gooood story that's new okay so the good on each episode yeah see right here actually the gooood is actually the in this instance the post with the you know the actual unit string yes and and we're ready so the plug-in is enabled and it was integration hub standard is what contains nice and I didn't have been enabled already you did not need to do a refresh or something on that to get it yeah you're gonna have to fully reload your your flow window all right we'll do that why is that Andrew because when flow designer opens up it loads a bunch of stuff at open time so that the page is responsive and so reloading it does not do that full reload right all of the the cache stuff that it loads so yes everything last video I made some changes to the to the into an instance before and I had to tell people to close the studio and then open it back up so you can kind of reload everything alright so here we go I got a feed I'm for each one I'm gonna be doing something so just isn't in action or didn't you make a as I did to build an action using this yeah so you're gonna need to build an action and inside that action you're going to use the parse XML but he's already she's already got the action near there he's already got an action then he needs to edit that action rather that's gonna read your read RSS and just a quick tip you can launch that from inside of your flow yes you can the top right so go to your flow mm-hm and in the top right of that line the rightmost icon so when your mousing over it is open you know action of course you need shortcut cool yep I didn't know that got it hey look at where did that show up Orlando I think that's been there all along okay it's definitely not Orlando though Andrew with the quick tip of the day all right so all right so I read the initial feed right and then this step I need to ditch right so don't kill it for now but yeah add a new step below add a step 3 so you want to below her we can move we can move the steps well you may need to do some pre-processing I don't know yeah and you take response body and do something with it does it not want to I did not bring up your modal and I'm looking I'm waiting click I don't see any waiting for in your browser mmm this is riveting video everybody that is yeah it's exciting riveting please put up the privacy shrubbery close close the action and open it again let's just try that just yeah that tab and then relaunch it Earl Duke says uh drink when someone says to refresh the page look at this all right that's that's troubling undefined your action just went yeah all right let's do this we should do a full refresh again - dude did you try turning it off and on again alright so I find myself launching flow designer from the standard UI more often because it comes up in a tab rather than separately I know I do the same thing Chuck because I knew there was an option - Saints have yeah you're right yeah you're right I do like that better this is more promising oh come on load oh really throw the chicken bones all right you know what come on try something else I mean just a new create a new action let me open up Chrome I'll uh I'll try and verify if I'm experiencing the same issue with your action as well was this the read RSS feed or read RSS XML reader RSS feed okay you're still up done Andrew yeah that didn't close the instance st uh yeah I'm having trouble like adding a new step mister a browser oh yeah check the console log maybe we should enable this plug-in before we started I mean maybe I am I am getting a 500 error role flow designer 500 ok yeah that's a server-side thing yeah oh there yeah hey you fixed it Andrew that's right good job just look at the console log that'll fix well I looked at the console log and I gave it a cache - and so for the people that are watching this and if you're still with us yeah the plug-in that you enabled is that a pay-for or is that uh free standard okay the only one that's available frees the starter pack is is it paid for but many customers have that and it's cult standard because it's at the bottom so this is something that most people with may have right yeah most people should have access to the XML parsers tab alright there we go alright source data I guess response body that seems reasonable all right so wrong edit mode all right so so this is where it's helpful to collapse like the the left hand side steps just give us a little more real estate so we can see what we're working on gonna get on and I'm trying to remember but I think the best thing to do is grab one of your payloads and drop it into this box and that will start to generate your your object subject from that example 100 so go grab literally cut and paste yeah literally cut and paste get that XML feed that you had it's been a good seven months since I've done this and we only did it once but that's what I recall 15 years with a podcasting cut paste okay oh I don't know that I pasted that whole thing I'm just kidding it's not that big okay listen one example would be good 20 million no no we but we actually there's a limit on how big your RSS feed can be sighs wanna so yeah it would never be this big or that day it should be it should over woman so create an object generate target generators Oh see I think RSS feeds are a little little weird hmm why all right so let's go take a look at the other feed I got and see if that one's in the better see if we can get a smaller and starter example yeah [Music] 4600 lines is a lot hmm no all right well now I'm starting to doubt that the browser is still happy with us well channels Hey item I missed it would you do to get that going I changed it from raw edit mode to structured oh that looks better I'm able to the structure yeah yeah okay yeah but that's we still need it to generate the the complex object on the right but we could do that and create object is at this point isn't it just mapping that's a lot of mapping that's why he doesn't need everything though yeah all I need is really one item right and kind of a few things out of the item yes right so you need your what do you wanna call this channel and then in each channel is an array of items copy to clipboard I wanna say that I was curious what it was gonna do I control a alright so title name no no no no no title is inside an item you got to get down to the item level first there is right there no your your way inside of channel mm-hmm you won't you you're gonna get 17 episodes and you're gonna put them all in one object called item no oh okay all of them I'll say this is retinal is going to be an object for this should be like item of items this should be items and it's an object and then I want to add a to be channel okay all right help me out here Brad yeah we want the the the complex object to relatively mirror the the incoming object yes sir the few missing pieces down at the array of items all right yeah you're gonna have a channel title down the channel part I don't really need so much but I'm gonna add a plus a link whoops link probably description okay and I assume those are all strings right yeah do you want anything your own last build date or anything no I should be getting that from the items iTunes tag you probably look great could you do me a favor and and that last XML copy you did can you just drop that to me in a slack here I'll send you the address how about that yeah that the Earl is great if that's what you have yeah there I am I went to the store today I always feel really bad because I have a hat on dark sunglasses and a mask no no I couldn't hold up anything I want at this place all right hey here's my boss look he's gonna go bomb someplace right blaze like I'm just getting some groceries there you go thank you that's all right I wore that mask into a liquor store so I was like tell the guy said no I'm not gonna rob you that's what I did too I was walking in whistling okay so now we need you've got what you need out of the channel heading I think so cuz I don't really do much with the channel part but you know if it's there maybe later so yeah okay now you need to add mm-hmm items item item item it's going to be an array you never addressing arrays items keep your things singular it's easy to remember a gray object I need I need Brad and Andrew to help back up on this yeah you'd want to rotate through the object right and that's how you defined an array of objects is a red-dot object yeah so you make an array or you make an object and you push it into an array okay go for it yeah names racket and then under there you see how you get another little plus I'm one are building your array object well now you're you just I think you scrolled off the screen and what people can see now I was truck sorry I was trying to make a little room so I could see median and slide it to the left you know what you can look at that okay all right so item child zero so this is where I get title yes yep oh we didn't want to add something under there that's something under here how do you do it just under it a plus way up on top again okay drag it over don't I did take a moment and validate at least that the XML parser in my instance which is long installed this and used it problem with their indentation on this object we don't want something at the same level as item no I want to like add here oh you have title as an object that's why Oh so the the things under oat idle mostly so a radar object is gonna have objects under it right oh it's all it can be as objects under it it yeah so a raid out object is is a bunch of objects yeah right correct yeah so there's your array this is technically the right and there's item should probably be more appropriately called like item list yeah that's what I was saying items because that would be the plural of all the items on there that seems kind of crazy why do you need to reference items dot item dot title items does nothing for you I'm I'm thinking like JSON this would be the the square brackets part but now you got to anyway well like here their items would be which contain each other should be that should be item change title item yes you're right it just looks like one level of indirection we don't need yep very good that's where we want it now here's how under tight object we have yeah strings title let me expand that back out so I can see what I'm talking about link good this is the part where we're going to see what happens yes um description enclosure and for those playing along at home the enclosure tag is what actually turns a regular blog feed into a podcast feed because you guys right it's like a file attachment I like how I'm thinks this is wrong alright I'll guide I think nope update we have three category tags what's up with that pub UB pub date I think that's pretty much at least for now I think I'll be fine okay yeah enclosure say this is gonna be interesting the enclosure which is not showing there but you know it has elements inside the self enclosed tag so I'm curious how that's going to show up yeah that's interesting because what does it get what does it do with the attributes on an XML tag I have a feeling that this needs to be object well technically any of them could be objects well this is a date this is a string it's just and then this is a string so that that's the sister or oral this one has elements that I need to keep so I'm having a three I have a feeling that you know because in an enclosure you have your the filename the size um the type of it it you know if it's a video that probably should be an object itself yeah I believe it's an object and then you're gonna add the fields that you need under no look that's right what is that insert item huh that's interesting oh you could put one in between yeah that's cool all right so then something new question line is for things under and then the plus between lines is for inserting new rows of the same hierarchy level come on add your your enclosure problem not actually wowed about some of the UI and flow designer of being hidden all the time and yeah mouse-over exactly the right spot but you know they should have had like a little small indicator or something and then make it big you know pop what were you saying well you'd say I need you need to add the properties to your enclosure object yeah you've got to add the new all right so we'll say type filename here let's go look at one the size is at length and close your Oh Earl length and type Earl length and type Colonel we already get tight there you go all right I think I think that's good okay okay what now guys side down Andrews not optimistic you seen this show too many times right so we're skeptical people we we want to be happy we we just you know are enjoy the getting the getting there right alright so what do a test what's that breast saving I'm so nervous you know check other day Chuck said just use the XML parser I'm like what else you know it's what XML parsers I spent an hour looking for it I was like cuz I didn't want to go back to Chuck and look like an idiot and you know be right in my face I looked around it wasn't there we do a test on our action so now we can do it too yeah we can execute a test from right there all right moment of truth and so you'll give it that is that the smaller or or the bigger one yes well it's not that somebody sent me no it's the how you use it all right let's try this one this is ours this is Chuck and oz okay both oars there's a lot of legacy in that feed it doesn't work I'll swap it out what the other okay executed well yeah it's viewing we get let me get you you can still have a right big old error that is the largest flow designer error I've ever seen grace it's obvious didn't do anything settle at all okay so oh oh the script script let's comment that all out then or just remove it all right so go schema structured here's the payload did you know he's gonna see did the other one work it apparently did cuz you've got a whole bunch of stuff back oh yeah no you cannot open up oh not run yes step so that we don't get this error yeah sorry let's take this script step out and that was gonna get very large error though you're so gonna get an Erica is gonna say hey wait feed items yeah just take the step out I guess I can remove it it's not a big deal it's not doing anything for us anyway and if we do we can throw it in there you know what was weird I'll tell you I'll just share this real quick I did the output variables and it was like I couldn't ever figure out how to map this back I was trying to get JSON and tar stuff I couldn't figure it out and maybe it was just me being stupid but I had a lower cut output there you know mapping that stuff is a little tricky the first few times you do it mm-hm we've we walked through all that stuff last year on the show so we so I appreciate the your your woes there you know it's it's not super straightforward the first time you were using complex objects and the inputs or outputs of uh flows you're I'm returning error in the transform let's see the steps yeah so drill into the steps okay first one ran we got our feed alright maybe we pass it an input oh we did I saw it in the okay it was a data pill in the input there we must review that because that was making a lot of changes before let's cover view though check the inputs and outputs because I'm not inputs that's all that's your action input mm-hmm we're excited when he ran the action okay on step two you are we consuming that step one so one action Earl and it's going to automatically output a response body response headers all that stuff and that's what anything input here is the response body which should be right yep yep so let's go take a look at the response body in the execution and see that that has a valid payload that we're looking for all right I'll close the thing so let's test just again oh just open the execution but the executions yes scroll down just a little bit into that first steps response body so scroll up a little up the response body in him right there that blue text on the right bottom mmm there's your response body so the first ones the header and the second ones the body so clear the way around first ones the body yeah body and hitters oh look at my bad I couldn't see to the left yep there you go gutter and is this what we expected yes it looks like it is mm-hmm so now so that's the input turn null as an output so something didn't there's the there's the feed okay and what is the target schema is there values in it on the right hand side yeah yeah open that up no values it's got the structure mm-hmm that's the right number of objects in your array it's probably more I'm sure there's more but yes item link oh no this is the this is all you know it must have not a parse the XML because it looks like the structure here is for at least one item you know one yeah of everything so it didn't feel anything and and I think the the rough point here is that if the generate the complex object from your example which is this XML that we're passing into it doesn't work then just generate just putting in the structure we want also isn't gonna work let's let's do this let's try the other feed just a time it's to see if our friend mark is doing his better I don't think it will cause our definition isn't working it's not the feed it's coming in there yes sir good yeah you don't want to run you want to try this one ah that will almost certainly fail right because our structure isn't the same is it and well the structure is the same it's just what it is we don't have we don't there's the definition phase and then there's the execution phase the runtime piece we're retrying the runtime piece when we know the definition is wrong yes well you know what so to to get these to map properly what do these next these names have to match the names over here how do you get that sell it that's a belief how it works is that the names need to match so shouldn't we should we have a parent RSS object that's that's how the auto-mapping works okay so because our generate target didn't work we're oh so you think I need to add one one above for RSS and then Channel and then I thinking yeah it's like we jumped in I'm not sure if the RSS part is needed or not but maybe it's an actual structure there's a there's an RSS and a slash RSS outside of channel and slash channel how do I add one at the top just add it below and drag it up all right so this RSS would be this would also be an object yeah there you go right there no okay can you drag it the top no Channel can you drag channel inside it yes that was neat I'm glad we've saved yeah yeah that's the comment we just got in YouTube as well shouldn't you be starting with the document RSS yes yes we sure yes we should know hmmm alright yeah how do I add something and you says try a blog RSS or something simpler to see if it'll work we could go get go get an RSS look straight from a blog yeah grab the developer sites blog RSS yeah I'm just trying to figure how to I have an idea alright this is how we want to call it RSS done yeah the labels probably not the important part the names probably the mo oh I can't change it and Channel yeah yeah that's I think it's angry with us yeah you kidding me open with left wait hold on come on you hover over that again said open with left something you had a little hover a pop-up that popped up when you were in there how we can't get it back peg you got to stop and read once in a while there oh oh that's wrong should never mind so all right so can we indent I'm up for trashing this and starting with that yeah yeah all right if it'll see if it'll auto build us one with the blog yeah all right I like it blog we tried to roll our own we go vlogger old do you have one and we can use ya the developer site developers now.com do how do you get the RSS out of there though there's RSS link right at the top of it chorus is nothing I mean what you say blog blog do blog that do either here alright so it go back to raw yeah raw then select all I'm paste somebody needs to visit their XML Wow well okay well let's let's grab a more generic somebody somebody out there and there the world got us a generic RSS feed the wrong stuff is what ander said what did we copy whatever I didn't see what you copy oh wait wait wait wait wait oh well you copy view page source here you go the browser that's what you want yeah you got like the crazy characters in there although I didn't see them all right uh no the thing isn't lit up still not formatted properly let's reload it hmm formatted properly hmm I don't believe you oh it's all is it all encoded for some reason when you copied it it encoded it and that wasn't very nice paste in there what do you get that looks normal yeah I don't have the oh yeah yeah I didn't want to do that that's color coding it let's try it raw edit mode what else is on there raw edit mode there structured and what else what's all the way at the top and there wait a minute hold on in it he says what yeah it's just rigor I was looking at our feet I was making sure I didn't get like the pretty five version earlier but yeah it's just blanks I shouldn't matter anyway shouldn't matter um interesting okay that doesn't look encoded to me anymore get rid of that what are the payload views structure draw edit and the rest truck yes he keep going right past it that's your three times oh this yeah what are the options under there the the structured or the raw edit mode where it gives you the three choices you know told me what the third one is yet oh there wasn't a third choice yes there is third choice yeah what's it I don't know oh I saw three because there's what the one that's selected is in the list okay hmm that's funny though it can break it out then one we got so if you've got this you're going and delete everything in there because we know that's wrong right that's what we originally tried to create ourselves delete all that that's just as a generate target right now yeah it says it won't unable to generate so let's just add a couple of up to title and just see if we can get some stuff out make it make it a simple complex object yes that's RSS it's an object and that looks like it does need RSS at the top with an object okay so I think I did just parse one and it did need RSS at the top okay so and then let's get title yeah and make that run string you viable product actually save first an end of saying the most common problem is missing like a close tag on XML here I was looking to make sure I had the and we got a trace a stack trace with a nullpointerexception that's an angry error or fun no there's that's it get much simpler than that well the input is still complex so true if it if it fails the parsing because it thinks it's invalid xml then just just for kicks wait a minute wait wait wait wait wait go do you know it's not gonna work no way we gonna say take a look at that the xml that you had in your text editor or right from the web browser wherever it was oh here yep that first line says angle bracket question mark xml mm-hmm do they all say that yes cuz it's an XML file they don't just start out with like HTML is a version of XML but it doesn't have that is that what's possibly screwing us up maybe we do need that scrip to strip out a line here let's do this closure tag for that let's do this go do go look at a show XML I like an incident record or something all right so let me do ROI edit mode okay take that first line out I did it I didn't copy it okay generate yeah oh so close okay so it was it was turning it's thinking hard well it's still filtered it figured it out kind of wait a minute okay create an object you know what I have a feeling RSS copied shouldn't it be like you want to explore objects background scripts Explorer or Explorer you try no what's the I'm putting the XPath in there yeah that shouldn't should not be necessary really all right hold on I want to you're in the label anyway so that's not gonna buy you anything no it's translating the slashes to underscores it's not yeah it is but I think name that should be and what I have title you're just affecting the label though you could call it foo bar and gum I have a feeling either one of those needs to be [Music] I'm sorry hmm okay all right fine but you see what I was getting at as I wanted to take the path the XPath of these elements and place them in here could it be this needs to be yeah it that that's not how this the it does the parsing it does it based off the structure so unfortunately so there's there's two options here there's one that we can figure out what it dislikes about your XML and script adjust that and then pass that into the the parser or we could just script the parsing these are the two choices that are available to us right now all right because if it doesn't like the XML as it exists as it's coming in it's not going to do the auto parsing because it it doesn't understand it it can't move forward and this XML parser is is is fairly it's not as forgiving is for example an RSS reader it's you know those have lived with weird X you know weird things for long times right and have all sorts of complex things and this one is a fairly simple one so we can either adjust your data to get it into the XML parser or we can just parse well I think it's adjusting the data is not really an option unless we run a script on it and then make changes but then the problem seems silly because I could just sparse it then well my feed and the other feeds should all pretty much be similar so it should I should just have a script to just parse it out if the the XML partial step isn't going to we're gonna have that RSS Channel instruction oh yeah absolutely yeah so I think we just parse it with script is all right thank you XML parser for nothing yeah okay we have four minutes go Craig four minutes let's parse it all right so we want a script right so we want a script and then the the biggest thing in our script here is going to be creating the output complex object which is basically what we were doing in the XML parser is we need to well it depends on how you want to use the the object in in flow designer is to how detailed you have to craft the object so if you want individual data pills that you can like drop into and consume you need to build the object as we were basically building it in the mmm-hmm the parser yes oh really I'm probably think is what you need yeah because he's gonna be populating fields on a record yeah so I want fields on a record and I really only need all of those items I really don't I don't need you know I don't need the chain because that's already submitted when the when the user is participating you know they some they fill out a form and submit their stuff so I already have their description and their feed and all that stuff I just need to go and parse through the items and populate that items table with that stuff so let's create our complex output object with alright like just just a super super minimal viable data structure and then we can quickly make a script to grab that and populate it and test it I think we could do that in just a few minutes sorry so data in response body BAM and now let's go down to that item well the response I just call our assad's body oh yeah I'd call our response body because it's not it's nobody so I don't get confused that's one but response Bobby okay response Bobby yeah and now go down to that outputs area and create our variable down there alright so we wanna yeah so this is gonna be our object level right mm-hmm so item item or items because item is a list of items that's what I'm getting it is we should come out of this script right yeah it should be your items list I think okay items list all right podcast list or whatever and so that's your object I mean want this to be an array array object array object alright then objects under that is your item and then the first level is what was that title XI title that's as simple as it gets but let's give it one more just just for funsies you know what the gooood yeah alright oh we can just the new create or update record eventually that's exactly what I'm gonna do because I don't need to update I don't need to keep adding if there exists yeah now in this video we'll look up either let's take our input stop response body parse it and then map the outputs okay so it's gonna be input you know so you're you've got to start with the inputs that response party and then we're gonna like parse the json parser it's not json all right absolutely now chase some parts that and I think that's where Craig was getting stuck before on the pure script solution was the XML document parsing stuff yeah right that's right so you okay input stop response body you want to assign it to something yeah that's a sign that and please God don't end up using XML to JSON in this script yeah I mean I've done it before there's a data okay I dated equal a proud of it but all right parsing this XML what's the best way we should have purchased or should we even try I mean we're we're basically a time here but so at the end here we're gonna do you know output so we're gonna have we're gonna create a probably an array of objects and we're going to assign that to our output right so with that that part is fairly straightforward so we're gonna you know we've got items and then you know then output dot items list is gonna be items like that yeah so this is they are structure you know and now we have to walk through that XML and grab the variables we want and you know push them into our our items object and then you know have victory from there but that's a like sure item it's so much better when the exome XML parser will work though that's why we came up with the XML parser so we don't have to do this part yeah I know this isn't right but I'm just gonna type it out here item that title you don't know what title is yet though you have to parse that out of the XML right yeah I don't know it what do we say title um though that was a trite title and Glee oh that was it okay so there's that and then it's not push I don't know be I don't push items plural I'm sorry I don't yeah I don't see yeah alright and this of course will ever be a loop through the through something yeah and then then we would assign that and away we go yep all right what let's drop out of share it was a noble first effort right it wasn't it was worth a try to use the the parser which which is great when it works as usual with things right and you have to build your own object yeah oh so so that that's a you know not super unusual case though is that your input that you're trying to get might need some massaging before a parsing engine can parse it and if you know what those weird edge cases are you can script that and if you don't you don't use the parsing engine right right those are those are basically your choices is if you have known errors in your input from whatever system you're importing in then you adjust them then you run your your regular and this can apply not just you know parsing like XML but your your data source imports you know with transform apps and things like the these sorts of ideas apply across the board which is if it's a known air-cool I can handle that case and then I can pass it into the easy stuff and if it's unknown errors that I know about then I can't use unflexible automation things I have to have to have flexible automation things involved then like writing the script ourselves Indian walking through it versus you know an automated system so bread house chat Chow it looks good right that looks good it's pretty active today like some suggestions and discussion I mean there's always grow yeah there's no success factor for beers today there is no success factor for beers today that's right so I didn't serve beer yeah we're delighted to have had Craig on today and and we'll help him finish his parsing offline but but this was useful you know as as everything on the show we don't practice this we don't know where the weird problems will be like the only weird problem could have been the plug-in wasn't install that could have been our only problem today it wasn't but I was really hoping for that to be the case yeah that would be great with when that works it's pretty magical the the complex our object parsing and in creation like that it's the same with the open API specs for rest those are fun like when those work when the spec they provide is a valid spec and you could just import it and get all the methods and so and the method in puts and outputs and all of that's automatically defined it's so magical when it when it doesn't you you can't a big sad because it's you know it's super inflexible we don't have the ability to adjust those on the fly it either works and it's magical or it doesn't work and you have to do it the other way so this is pretty generic problem that we ran in today I appreciate everyone's participation let's get on to rating our drinks Chuck how's your grapefruit today gone it's gone oh there's good grapefruit is a nice white grapefruit I'm gonna give it a 4.5 I like grapefruit juice noise and this is out of the scale of five in quarter increments Craig okay sure words like untapped yeah untapped alright I'm gonna give the white cloth since it's not a beer per se I'm gonna give it a four point two five about that point you found all right it's refreshing refreshing go to refreshing in light so it's good alternative to beer if you're interested in white clothes are good Brad my Kentucky Bourbon Barrell there we go it gets a four to five it was excellent but we were not successful and and my old Tuffy was it was a fine New Belgium it it's probably something like a 375 but with the with the mister wolf on the logo it's a solid four okay four do we have any crater cone or hackathon news or anything we need to share before absolutely I was gonna say Brad tell us just a moment about the hackathon that's coming out we do have some hackathon news so just as some context the hackathon is gonna run the creator con hackathon in that's running with knowledge is gonna run May 1st through 3rd in the US it's going to run the end of the day east coast on the first which is a Friday through the end of the day Sunday on the 3rd and we have a lot of a lot of information about it that you can find online and we point to it from all sorts of places but the big news for today is we finally got our prizes approved by Chrysler meant a new class so we are going to give out the equivalent of a $5,000 grand prize probably through a Visa gift card to the winning team and then the four runner-up teams will each get I think $500 us for winning their categories green eyes I'm so good this year we think where can they find out and sign up we don't create a link it's a half now service - now calm / creator developer blog there it is it will be one of the prominent blog entries on the left fellow pad service now calm look for that yeah that's better than my and so knowledge and creator con is certainly coming up and hackathon is part of that so we're looking the registration is up the scheduling is still not up but it will be you know in the future up and I know that the three three of us definitely have sessions that that you'll want to join in Craig is an enabler to make sure that we can have sessions yeah I'm like atlas I got it all on my shoulders the three of us cannot be successful without Craig that's right so we definitely will share more on the blog about which sessions we're going to have and which things are interesting we look forward to sharing some more about that next week when we have even more details that we can share publicly but as always thank you all for joining us thank you particularly Chuck and Craig for having an interesting episode today I'm sorry we were successful today but we learned things along the way which is the point of the show that's right because we're not here to you know deliver sprints and stories you know superfast we're here to help enable other people to succeed in and the best learning happens when you fail that's right thanks for nothing guys so much I failed I failed many many times yeah failure is always an option that's right so thank you for joining us everybody have a great weekend and we'll see you back again next
https://www.youtube.com/watch?v=SkPfpoxPTiQ