私はPerlが初めてです。xml のルート タグとルートの終了タグを perl 変数に読み込みたい。
この通常のファイル読み取りを試しました。出来た。最初の行と最後の行を取得しています。しかし、新しい行がない場合、最初の行を信頼できない場合があります。そのため、最初の行を読み取るための正規表現を使用します。
しかし、これを行うために組み込みのPerl xml関数を探しました。私は何も見つけられませんでした。つまり、すべてが私にとって新しいものです。
これに最適なライブラリを教えてください。可能であればいくつかの例。
例えば:-
<nst:root arg='1' arg2='2' arg3='3'>
<a>1</a>
<b>2</b>
</nst:root>
私は2つの変数が欲しい、
$root = '<nst:root arg='1' arg2='2' arg3='3'>';
$rootClose = '</nst:root>';
このルートタグを他のxmlに置き換えたいです。助けてください。
これが私がやりたかったことです。xml ファイルがあり、実際のルート タグがあります。を使用してそのファイルを複数に分割しましたXML::Twig::xml_split
。多くのファイルを取得しますが、ヘッダーが異なります。メインファイルの実際のヘッダーで子ファイルを更新したい
例えば:-
スプリットリミットは2
実際のファイルは、
<nst:root arg='1' arg2='2' arg3='3'>
<a>1</a>
<a>1</a>
<a>1</a>
<a>1</a>
<a>1</a>
<a>1</a>
</nst:root>
で3つのファイルに分割されますXML::Twig::xml_split
。そして、プラグインは独自のヘッダーを追加します。
File1:-
<xml_split:root xmlns:xml_split="http://xmltwig.com/xml_split">
<a>1</a>
<a>1</a>
</xml_split:root>
File2:-
<xml_split:root xmlns:xml_split="http://xmltwig.com/xml_split">
<a>1</a>
<a>1</a>
</xml_split:root>
File3:-
<xml_split:root xmlns:xml_split="http://xmltwig.com/xml_split">
<a>1</a>
<a>1</a>
</xml_split:root>
みたいに欲しい
File1:-
<nst:root arg='1' arg2='2' arg3='3'>
<a>1</a>
<a>1</a>
</nst:root>
File2:-
<nst:root arg='1' arg2='2' arg3='3'>
<a>1</a>
<a>1</a>
</nst:root>
File3:-
<nst:root arg='1' arg2='2' arg3='3'>
<a>1</a>
<a>1</a>
</nst:root>