Hi,
Thanks a lof for the fast reply, here is an example, Is not the real script but is reflecting the problem of extarcting content from XML and trying to past it into other XML file:
#!/opt/perl/5.8/bin/perl -I /fw/subsystems/loc/tools/loca/mod/ # /fw/subsystems/loc/tools/loca/OLDDB_to_LOCA.pl use lib "/fw/subsystems/loc/tools/loca/mod/"; use strict; use Encode; use XML::XPath; use XML::XPath::XMLParser; my %SubstituteHash; my $SourceHash; my $import_xp = XML::XPath->new(filename => "russian_test.xml"); open (XML_DIFF_FH,"> test_o.xml") or die "$!"; binmode XML_DIFF_FH, ":utf8"; print XML_DIFF_FH "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Transl +ation>\n"; my $import_xp_nodeset = $import_xp->find("/Translation/String"); foreach my $import_xp_node ( $import_xp_nodeset->get_nodelist ) { my $CurrentStringId = $import_xp_node->findvalue("\@name"); $SourceHash->{$CurrentStringId} = $import_xp_node->findvalue("val +ue[\@language!=\"English\"]/text"); $SourceHash->{$CurrentStringId} = pack ("U*", unpack("C*", $Source +Hash->{$CurrentStringId})); print STDERR Encode::is_utf8($SourceHash->{$CurrentStringId})?"1": +"0"; $import_xp->setNodeText("/Translation/String[\@name=\"$CurrentStri +ngId\"]/value[\@language=\"English\"]/text", $SourceHash->{$CurrentStringId} ); print XML_DIFF_FH XML::XPath::XMLParser::as_string($import_xp_node +) . "\n"; print XML_DIFF_FH "<test>" . $SourceHash->{$CurrentStringId} . "</ +test>\n"; } print XML_DIFF_FH "</Translation>"; close XML_DIFF_FH;
[download]
About the target file for russian, pasting the file corrupts the encoding, I'll try to upload the file. Pasting, just to let you know the schema used:
<?xml version="1.0" encoding="UTF-8" ?> <Translation> <String name="cprtConsoleYES" translate="yes" ID="137856" context="YE +S button prompt for PML messages."> <sizing type="LynxOS" height="0" width="0" font="CP" fontSize="10.5" + bold="0" /> <value language="English"> <text>test</text> </value> <value language="Russian"> <text>Да</text> </value> </String> </Translation>
[download]
Well, I wasn't able to know How to upload a file, I'll upload the file under teh following link: Source file: http://www.losinguanzo.com/utf8/russian_test.xml The file generated with this script: http://www.losinguanzo.com/utf8/test_o.xml The pasted script: http://www.losinguanzo.com/utf8/test.pl Thanks a lot for your help. Inguanzo

In reply to Re^2: Using a variable with UTF8 content coming from XPATH findvalue by inguanzo
in thread Using a variable with UTF8 content coming from XPATH findvalue by inguanzo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.