1

Hello,

In my application im going to use cxsd module in order to generate a Typescript class from a given xsd. The application is fed by xml inputs that I then do some logics on, converting the input to a known object by another web service and send it to the web service.


For example, recieving a DogXML input -> converting to OutputDog -> sending to the webservice that expects the OutputDog


I couldnt find converting the input xml to the output object so trivial. Writing an application with Typescript made it clear for me that i need to somehow parse the xml input to the generated Typescript classes by the cxsd. my question is how?


How do you parse a given xml to an instance of an existing Class?


What i want to achieve is :

  • Recieving a DogXML
  • Creating a Dog instance of this xml
  • Do logic and convert it to OutputDog
  • Send the OutputDog to the web service

Currently i am using xml2js module to convert the input xml into a JSON and work on it, the problem is that the output of the parsing to JSON is any and I cant access the properties of Dog since it doesn't know Dog's properties. This is why I need to create an instance of Dog from the given XML


Thanks in advance, hopefully i made myself clear!

5
  • this might be helpful (explained how to convert json to instance of type) Commented Jul 14, 2016 at 6:12
  • Did you have some Code? Commented Jul 14, 2016 at 7:34
  • @Magu i dont have some code that i can upload here. Commented Jul 14, 2016 at 8:42
  • @AlekseyL.converting from json to an instace is something im able to achieve with TypedJson package. but i recieve alot of input, and would like to do it right away from xml to an instance Commented Jul 14, 2016 at 8:44
  • Would realy appreciate help, still have the problem.. Commented Jul 21, 2016 at 6:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.