Javascript 将US Word从XML文件替换为UK Word的最佳方法是什么

Javascript 将US Word从XML文件替换为UK Word的最佳方法是什么,javascript,java,xml,xml-parsing,Javascript,Java,Xml,Xml Parsing,我的每个页面的文本都在外部语言文件中定义。例如在somthing.xml中 如何将somthing.xml中的拼写从美国英语自动更改为英国英语 在somthing.xml中,我知道我可以对我想要显示的每个文本使用str_replace,但这将非常耗时 所以,我需要将US Word从XML文件替换为UK Word的最佳方法。还有解决这个问题的字典API吗 我的xml文件: <?xml version="1.0" encoding="UTF-8"?><?mso-applicatio

我的每个页面的文本都在外部语言文件中定义。例如在somthing.xml中

如何将somthing.xml中的拼写从美国英语自动更改为英国英语

在somthing.xml中,我知道我可以对我想要显示的每个文本使用str_replace,但这将非常耗时

所以,我需要将US Word从XML文件替换为UK Word的最佳方法。还有解决这个问题的字典API吗

我的xml文件:

<?xml version="1.0" encoding="UTF-8"?><?mso-application progid="Word.Document"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:name="/_rels/.rels" pkg:padding="512">
<pkg:xmlData>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" pkg:name="/word/document.xml">
<pkg:xmlData>
<w:document xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:body>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM THAT ALL AUTHOR INFORMATION, INCLUDING NAMES, AFFILIATIONS, SEQUENCE, AND CONTACT DETAILS, IS CORRECT.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE REVIEW THE ENTIRE DOCUMENT FOR TYPOGRAPHICAL ERRORS, MATHEMATICAL ERRORS, AND ANY OTHER NECESSARY CORRECTIONS; CHECK HEADINGS, TABLES, AND FIGURES.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM YOU HAVE REVIEWED THIS PROOF TO YOUR SATISFACTION AND UNDERSTAND THIS IS YOUR FINAL OPPORTUNITY FOR REVIEW PRIOR TO PUBLICATION.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM THAT THE FUNDING AND CONFLICT OF INTEREST STATEMENTS ARE ACCURATE.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="AF"/>
<w:rPr>
<w:rPrChange w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z" w:id="6">
<w:rPr/>
</w:rPrChange>
</w:rPr>
</w:pPr>
<w:bookmarkStart w:id="7" w:name="aff1"/>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
<w:t>1</w:t>
</w:r>
<w:bookmarkEnd w:id="7"/>
<w:del w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="8">
<w:r w:rsidDel="00EC58EA" w:rsidRPr="009C081D">
<w:delText xml:space="preserve">International CyberCrime Research Centre, School of Criminology, </w:delText>
</w:r>
</w:del>
<w:r w:rsidRPr="009C081D">
<w:t xml:space="preserve">Simon Fraser University, Burnaby, </w:t>
</w:r>
<w:del w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="9">
<w:r w:rsidDel="00EC58EA" w:rsidRPr="009C081D">
<w:delText>BC</w:delText>
</w:r>
</w:del>
<w:ins w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="10">
<w:r w:rsidR="00EC58EA" w:rsidRPr="009C081D">
<w:t>British Columbia</w:t>
</w:r>
</w:ins>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z" w:id="11">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:t>, Canada</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00074820" w:rsidRPr="009C081D" w:rsidRDefault="00074820" w:rsidP="003E0D43">
<w:pPr>
<w:pStyle w:val="TEXT"/>
<w:rPr>
<w:rPrChange w:id="401" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:id="402" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:t>The online media output of extremist organizations has allowed their messages to be seen and heard by vast audiences, however, propaganda is even more effective when it inspires or pushes the individuals exposed to it towards radicalization or recruitment. Online media has become an increasingly important avenue for recruitment and has greatly enhanced the ability of extremist organizations to deliver their radicalizing messages (
</w:t>
</w:r>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:id="403" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r w:rsidRPr="009C081D">
<w:rPr>
</w:p>
</w:body>
我使用java代码,所以任何人都知道这一点。请让我知道

这有可能吗


谢谢。

这可能会对您有用:


使用DOM解析器。解析XML文件并读取“w:t”节点标记。然后使用Node.getTextContent和Node.setTextContentusWord.replaceAllword,ukWord。

您能否提供示例XML中存在的一些美国单词?您能否检查这是否对您有用:@Rajeev Akotkar,感谢您的努力。向我们展示类似组织的词汇,激进主义。。我还是没有检查你的答案。
 us_words_list = array('colors','flavors','organizations','radicalizing');
 uk_words_list = array('colours', 'flavours','organisations','radicalising');