2013-05-08 2 views
0

Xliff 파일에 새로운 라인/요소/내용을 추가하는 방법을 알고 싶습니다.xliff 파일에 새 콘텐츠를 추가하는 방법은 무엇입니까?

<xliff version="1.1"> 
    <file original="myfile.ext" datatype="plaintext" Source-language="en-US" target-language="fr-FR"> 
    <body> 
     <trans-unit id='#1'> 
     <source>Der Text.</source> 
     <target>Le texte.</target> 
     </trans-unit> 
     <trans-unit id='#2'> 
     <source>Das Flugzeug</source> 
     <target>l'avion.</target> 
     </trans-unit> 
     <trans-unit id='#3'> 
     <source>Der Baum.</source> 
     </trans-unit> 
    </body> 
    </file> 
</xliff> 

내가 <trans-unit id='#3'>

답변

1
const 
c_target='target'; 
var 
    i:integer; 
    NodeElement,NodeElement2: IXMLNode; 
begin 
    NodeElement:= XML.ChildNodes.FindNode('xliff'); 
    if Assigned(NodeElement) then NodeElement:= NodeElement.ChildNodes.FindNode('file'); 
    if Assigned(NodeElement) then NodeElement:= NodeElement.ChildNodes.FindNode('body'); 
    if Assigned(NodeElement) then 
    begin 
     for I := 0 to NodeElement.ChildNodes.Count - 1 do 
     begin 
      if NodeElement.ChildNodes[i].Attributes['id']='#3' then 
      begin 
      NodeElement2 := NodeElement.ChildNodes[i].ChildNodes.FindNode(c_target); 
      if not Assigned(NodeElement2) then NodeElement2 := NodeElement.ChildNodes[i].AddChild(c_target); 
      NodeElement2.NodeValue := 'l''arbre'; 
      //XML.SaveToFile('C:\temp\test.xml'); 
      end; 

     end; 

    end; 
end; 
<source> 줄 끝에서 <target>l'arbre</target>을 삽입 할 TXMLDocument 구성 요소

임 사용 델파이 Xe³