Question
· Oct 16, 2017

Need example for class method within EnsLib.EDI.XML.Prop (choiceGetCount())

Hello,

 

I've been manipulating XML objects via Cache, but have had some difficulty understanding how to use the following method detailed within EnsLib.EDI.XML.Prop:

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

From what I've read when walking through the code for this method, it appears to count a listing of repeating XML elements. However, despite my attempts to search for examples or attempts to implement this function, I am unable to do so.

 

Would anyone have any examples or ideas? Perhaps, at least, can someone tell me if I am using this function for its intended purpose?

 

Thanks,

-Mike

Discussion (10)0
Log in or sign up to continue

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