0
XML 문서를 파싱 중이므로 xml 콘텐츠를 태그가없는 일반 단어 콘텐츠로 변환하려고합니다.Perl xml을 워드 문서로 변환 하시겠습니까?
예 : XML 파일 :
<title>Introduction</title>
<sec>Welcome to this world</sec>
<ref>Conclusion</ref>
변환 단어 :
Introduction
Welcome to this world
Conclusion
사전에 어떤 제안에 감사를드립니다하시기 바랍니다.
이 코드를 시도했지만 내용을 XML 파일에 정확히 씁니다.
use Win32::OLE;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Word';
$Win32::OLE::Warn = 2; # Throw Errors, I'll catch them
use Cwd;
use File::Basename;
system 'cls';
#use strict;
use List::Uniq ':all';
use Sort::Versions;
my $xmlfile = 'D:\file.xml';
my $cnt = _open_utf8($xmlfile);
my $dir = dirname($xmlfile);
my $basename = basename($xmlfile);
my $wordsave = Win32::OLE->new('Word.Application', 'Quit') or die;
$wordsave->{Visible} = 1;
my $doc = $wordsave->Documents->Add();
my $range = $doc->{Content};
### insert some text into the document
$range->{Text} = $cnt;
### read text from the document and print to the console
my $paras = $doc->Paragraphs;
foreach my $para (in $paras) {
print ">> " . $para->Range->{Text};
}
### close the document and the application
$doc->SaveAs(FileName => 'd:\temp.docx', FileFormat => wdFormatDocument);
$doc->Close();
$wordsave->Quit();
_save_utf8($dir.'\\out_'.$basename,$cnt);
XML을 파싱하지 않습니다. 그렇습니까? 방금 읽는 중입니다. (1) XML 모듈을 선택하고 (2) 텍스트를 추출한 다음 (3) 간격 및 개행을 넣을 위치를 결정해야합니다. –