【发布时间】:2019-06-24 22:36:23
【问题描述】:
所以,我不知道这在 JS 中是否可行,我想做的是这样的:
我有 N 个对象,并想用它们制定一个 XML
import config from './config'; //that actually doesent matter
//just show it here because the xml that I return have a LOT of data
//from this config
buildXML(objects) => {
return `
<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<my-xml>
<id>${config.id}</id>
${objects.forEach(object) => {
return '<object>' + object + '</object>'
}}
</my-xml>
`
}
我想要这样的结果
<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<my-xml>
<id>42</id>
<object> OBJECT </object>
<object> OBJECT </object>
</my-xml>
有什么办法可以做到吗?欢迎任何帮助:) 谢谢!
【问题讨论】:
标签: javascript xml string foreach