xml and xpaths
Hey all I'm having troubles figuring this out.. so I have set up a datasource that pulls the xml directly from a bind statistics web server and that's working but I can't get the values to show up in the datapoints.
given this small snippet...
<statistics> <server> <boot-time>2021-05-20T18:36:19.674Z</boot-time> <config-time>2021-05-20T18:36:19.842Z</config-time> <current-time>2021-05-20T21:43:29.263Z</current-time> <counters type="qtype"> <counter name="A">448606</counter> <counter name="PTR">395691</counter> </counters> </server> </statistics>
When I try "/statistics/server/counters/counter/@name='A'", I just get a value of True back.
When I try "/statistics/server/counters/counter/@name='A'/text()", I get NAN.
Any ideas on what I can try ? I've been looking at xpath examples all day and haven't been able to figure out what's going on...
Additionally if anyone is interested I'll share the datasource after I'm done making it.. I was able to make a complex datasource for the boot/config times with groovy doing something like this:
stats = new XmlSlurper().parseText(body); rawDate = stats.'**'.find { it.name() == 'boot-time' }.text(); Date fd = Date.parse( "yyyy-MM-dd'T'HH:mm:ss.SSS", rawDate ); today = new Date(); timeDiff = (today.time - fd.time)/1000; return (timeDiff);
Then of course if we want we can set up a threshold to let us know if a dns server was reloaded (config-time) or rebooted (boot-time)