Help pulling multiple Attribute tag names and values out of XML and setting to custom variables.
If anyone could please help me solve this problem. Hopefully I can provide enough detail to show a clear understanding of what I'm trying to accomplish. Essentially APM parses SAML assertions automatically and sets this information as variables, however I want a way to grab these attributes and send them all to the back-end web server without needing to know what the attribute names are, because they change depending on application. So the only logical way I have found that I could do this is grab the assertion from session.saml.last.assertion and pull the information out my self and insert all of them through a loop as described below. If there is a more efficient way to do this I'm open to any recommendations to accomplish the task.
Below I have included a scrubbed snippet of XML out of a much larger XML which gets set to a variable that I'm pulling from. My goal is to take all attribute tags out of the XML no matter how many and set each of them to there own separate variable for additional usage. For example end result of below snippet would be:
Variables:
AttributeName.1=Email
AttributeValue.1=Johndoe@mail.com
AttributeName.2=Role
AttributeValue.2=GROUP1
etc....
Also I would love be able to count how many AttributeName variable where set so when I want to grab all of them and insert them as headers I can loop it and know exactly how many are out there.
for example:
set attrcount "Number of Attributes"
for {set i 0} {$i <= $attrcount} {incr i}{
HTTP::header insert "$AttributeName.$i" $AttributeValue.$i
}
I usually don't ask for this much detail on DevCentral but I'm a bit stumped on how to pull multiple tags with the same name out. I initially thought about using a xml parser but it doesn't seem like there is a whole lot out there that doesn't require a package such as tdom which isn't supported on the F5.
Johndoe@mail@mail.com
GROUP1