XML Correlate into non existent object

107 views
Skip to first unread message

Pauljh

unread,
Jun 25, 2013, 7:31:26 AM6/25/13
to intersystems...@googlegroups.com
Hi All,
   I'm suspecting the answer to this is use eXTC, but I have to ask anyway.   I have various XML's that I really don't want to create objects for and I'm not very comfortable with XPath, as such is there a way to correlate an XML to a none existent object?, and use the properties it creates on the fly?

   For example

<XML>
<Items>
  <Item>
    <Name>Name1</Name>
    <Description>Desc for Name1</Description>
  </Item>
  <Item>
     <Name>Name2</Name>
     <Description>Desc for Name2</Description>
     <Something1>Value for Something1</Something1>
</Items>
</XML>

I then want to have an object after an XML.Reader that contains obj.Name, obj.Description and for the second one object.Something1, but I don't want to create a class with properties, this data in the "object" will never get saved and so I'm not worried about storage, is this easily possible or am I damned to work out XPath?

    Regards

Adam Lees

unread,
Jun 26, 2013, 5:01:54 AM6/26/13
to intersystems...@googlegroups.com
I've never used XPath so I can't help you with that one.  I generally just use objects and Correlate because I know how to do it so it's quicker for me to code.  You don't need to persist them on disk though, classes which extend %RegisteredObject will do, then they just fizzle away when they go out of scope or when you kill the orefs.  As long as all the properties you need are in the class but they are not "Required", Caché will be quite happy correlating tags that exist into their properties and ignoring the others.
We use EWD but I've never got round to learning how to use the XML parsing functionality. 
Reply all
Reply to author
Forward
0 new messages