Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xsd将TypeScript对象序列化为xml_Xml_Typescript_Serialization_Xsd_Deserialization - Fatal编程技术网

使用xsd将TypeScript对象序列化为xml

使用xsd将TypeScript对象序列化为xml,xml,typescript,serialization,xsd,deserialization,Xml,Typescript,Serialization,Xsd,Deserialization,我正在尝试将给定的TypeScript对象序列化为字符串 我曾经使用xsd生成TypeScript定义文件,并能够使用以下方法将字符串解析为我的对象: import * as cxml from 'cxml'; import * as example from 'assets/xmlns/www.example.com/OrderDefinition'; export class SerializerService { constructor() {} async unmarsha

我正在尝试将给定的TypeScript对象序列化为字符串

我曾经使用xsd生成TypeScript定义文件,并能够使用以下方法将字符串解析为我的对象:

import * as cxml from 'cxml';
import * as example from 'assets/xmlns/www.example.com/OrderDefinition';

export class SerializerService {

  constructor() {}

  async unmarshal(contents: string): Promise<OrderDefinition> {

    let parser = new cxml.Parser();
    let result = await parser.parse(contents, example.document);

    return result;
  }
}
import*作为“cxml”中的cxml;
从“assets/xmlns/www.example.com/OrderDefinition”导入*作为示例;
导出类序列化服务{
构造函数(){}
异步解组(内容:字符串):承诺{
让parser=new cxml.parser();
让result=wait parser.parse(contents,example.document);
返回结果;
}
}
任何人都可以帮助将对象序列化回符合我的XSD的字符串


我确信有一个我忽略的简单答案。

是的,这正是我想要的——简单地说,如何使用cxsd?您是否正确地生成了XML?