Xml 以角度2+;

Xml 以角度2+;,xml,angular,Xml,Angular,我一直在阅读其他类似的文章,但我仍然无法在我的应用程序中正确呈现我的xml 我已使用以下方法准备好xml: const parser = new DOMParser(); const xml = parser.parseFromString(response, 'application/xml'); this.questionSet = xml.documentElement; console.log(this.questionSet); 这是控制台中的内容: 现在如何在H

我一直在阅读其他类似的文章,但我仍然无法在我的应用程序中正确呈现我的xml

我已使用以下方法准备好xml:

  const parser = new DOMParser();
  const xml = parser.parseFromString(response, 'application/xml');
  this.questionSet = xml.documentElement;

  console.log(this.questionSet);
这是控制台中的内容:

现在如何在HTML中呈现此内容

我目前正在尝试:

<div class="application-xml" innerHtml="{{questionSet}}"></div>

但它只是打印:[对象元素]


任何帮助都会很好,谢谢

尝试将
innerHtml
属性放在括号中:
角度安全性阻止HTML和其他脚本的动态呈现。您需要使用DOM Sanitizer绕过它们

请在此处阅读更多信息:

在代码中执行以下更改:

//在component.ts文件中
//导入这个
从“@angular/platform browser”导入{domsanizer};
//在构造函数中创建对象
建造商(
...
私人消毒剂
...
){
}
someMethod(){
const parser=new DOMParser();
const xml=parser.parseFromString(响应'application/xml');
this.questionSet=xml.documentElement;
console.log(this.questionSet);
this.htmlData=this.sanitizer.bypassSecurityTrustHtml(this.questionSet);//此行绕过角度模糊
}


您需要实现dom sanitizer。。angular security阻止了这一点我该怎么做?添加应答等待你能粘贴你的xml数据吗?在你的stackBlitz中获取[object Element]。你不明白吗?为什么不发布你的xml…这样我就可以检查了,因为它太大了!StackBlitz对你有效吗?StackBlitz现在有效,我的应用程序中已经有了它。非常感谢你的帮助。