parse XML to object
hi there,when i use %XML.Reader parse XML to object,if the element value is null,the data in the table is $c(0),how avoid this?
my class file like this:
Class M.PATLIST Extends (%RegisteredObject, %XML.Adaptor) [ Inheritance = right, Not ProcedureBlock ]
{ Property Data As list Of PAT(XMLPROJECTION = "ELEMENT"); Parameter XMLIGNOREINVALIDTAG = 1; Parameter XMLIGNORENULL = 1; Parameter XMLNAME = "DATALIST"; }
Class M.PAT Extends (%Persistent, %XML.Adaptor) [ Inheritance = right, Not ProcedureBlock ]
{ Property CSRQ As %Date; Property CYZZDBM As %String(MAXLEN = "", TRUNCATE = 1); Property CYZZDMC As %String(MAXLEN = "", TRUNCATE = 1); Storage Default
{
<Data name="PATDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>CSRQ</Value>
</Value>
<Value name="3">
<Value>CYZZDBM</Value>
</Value>
<Value name="4">
<Value>CYZZDMC</Value>
</Value>
</Data>
<DataLocation>^M.PATD</DataLocation>
<DefaultData>PATDefaultData</DefaultData>
<IdLocation>^M.PATD</IdLocation>
<IndexLocation>^M.PATI</IndexLocation>
<StreamLocation>^M.PATS</StreamLocation>
<Type>%Library.CacheStorage</Type>
} }
Comments
Please check the documentation here regarding the IgnoreNull property of the reader.
thks,i got it!
Optionally, instead of using IgnoreNull property of the reader, add to your M.PAT class:
Parameter XMLIGNORENULL = 1;