Mike DeMar · Oct 17, 2017 go to post

Creating a sample EnsLib.EDI.XML.Document class:

set writer=##class(%XML.Writer).%New()
set writer.Indent=1
set status=writer.OutputToString()
set status=writer.StartDocument()
set status=writer.RootElement("root")
set status=writer.Element("RepeatingElement")
set status=writer.WriteChars("Content")
set status=writer.EndElement()
set status=writer.Element("RepeatingElement")
set status=writer.WriteChars("Content")
set status=writer.EndElement()
set status=writer.EndRootElement()
set status=writer.EndDocument()
set xmlstring = writer.GetXMLString()

set xml = ##class(EnsLib.EDI.XML.Document).%New().ImportFromString(xmlstring)

As a test, I'm trying to call inherited function "choiceGetCount()" from parent class EnsLib.EDI.XML.Prop:

write xml.choiceGetCount(1, "/root", "RepeatingElement") // outputs status of 1

So, I'm not too clear on how this function works, or if I'm using it as intended. I'm attempting to output a listing of how many times a selected XML element repeats ("RepeatingElement" in this example).  Again, here is the function signature (I think "As %Integer" was accidentally omitted for formal parameter 'Output pCount'):

Method choiceGetCount(Output pCount, pDOMPath As %String, pRef As %String) As %Status

Thanks,

-Mike

Mike DeMar · Oct 17, 2017 go to post

I'm not really too clear on how to use the inherited method "choiceGetCount()" however. Would you be aware as to how, with my intentions detailed in my prior posts?

Thank you for your time.

Mike DeMar · Oct 17, 2017 go to post

You are correct, Eduard. Is there a particular function available from InterSystems that you're aware of to accomplish this?

If not, that's fine. I have something I've made myself, but was unsure if I 'reinvented the wheel' so to speak.

Mike DeMar · Oct 17, 2017 go to post

Publishing answer by Eduard Lebedyuk:

XPAth can solve that, you dont need to parse XML to object in that case.

Mike DeMar · Oct 17, 2017 go to post

Publishing answer by Eduard Lebedyuk:

XPAth can solve that, you dont need to parse XML to object in that case.