We are hiring intermediate or experienced Java/Jscript programmers right now. And we hope you can demonstrate your experience/learning ability by solving the problem below. It'll be a jscript function to transform a given format of XML input to another XML format.
The input would be like:
- xml version="1.0"?>
- <menu xmlns="">
- <menuitem>
- <node>1node>
- <parent>1parent>
- <name>parentname>
- menuitem>
- <menuitem>
- <node>2node>
- <parent>1parent>
- <name>1st childname>
- menuitem>
- <menuitem>
- <node>3node>
- <parent>1parent>
- <name>2nd childname>
- menuitem>
- <menuitem>
- <node>4node>
- <parent>2parent>
- <name>grantchildname>
- <attr1>helloattr1>
- <attr2>Worldattr2>
- menuitem>
- menu>
The output would be like:
- xml version="1.0"?>
- <menu xmlns="">
- <menuitem>
- <name>parentname>
- <menuitem>
- <name>1st childname>
- <attr1>helloattr1>
- <attr2>Worldattr2>
- <menuitem>
- <name>grand childname>
- menuitem>
- menuitem>
- <menuitem>
- <name>2nd childname>
- menuitem>
- menuitem>
- menu>
In the input format, tag "node" and "parent" specifies the structure of the tree, while "name" and others tags should be copied to the output format. Therefore, the code should be able to handle the following fragment of XML:
- <menuitem>
- <node>2node>
- <parent>1parent>
- <name>1st childname>
- <lastName>XialastName>
- <firstName>HaofirstName>
- menuitem>
For information on how to manipulate XML with jscript, you can check out MSDN's relevant section.
本文介绍了一项挑战任务:使用JS脚本将特定格式的XML文件转换为另一种格式。输入XML包含节点、父节点及名称等信息,需构建树状结构并保持额外标签不变。文章提供了输入和期望输出的例子。
1730

被折叠的 条评论
为什么被折叠?



