我的每个页面的文本都在外部语言文件中定义。例如在somthing.xml中。
如何自动将somthing.xml中的拼写从美国英语更改为英国英语?
在somthing.xml中,我知道我可以为我想要显示的每个文本使用str_replace,但实现起来非常耗时。
因此,我需要从XML文件中将US Word替换为UK Word的最佳方法。任何字典API都可以解决这个问题。??
我的xml文件:
ID Name ParentId
1 A 0
2 B 1
3 C 1
4 D 2
5 E 2
6 F 1
7 G 1
8 H 3
9 I 4
10 J 5
11 K 3
. . .
. . .
100 XX 9
101 XA 10
. . .
. . .
我的美国&英国单词列表如下,
<?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代码,所以任何人都知道这一点。请告诉我。
这有可能吗?
感谢。
答案 0 :(得分:1)
答案 1 :(得分:0)
使用DOM分析器。解析XML文件并读取“ w:t”(节点)标签。然后使用Node.getTextContent()和Node.setTextContent(usWord.replaceAll(word,ukWord))。