little problem with xml::dom::parser

Discussion in 'Perl Misc' started by mathias wündisch, Jan 22, 2008.

  1. dear group,

    i have a little problem with the automatic conversion from unicode
    entities in real characters by XML::DOM::parser (or XML::parser). for
    example i have the string '&x#A0;' in a xml source file and i want it
    after parsing with XML::DOM::parser also in the target xml file.


    begin source file:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <doc>
    <name>Mathias Wuendisch</name>
    </doc>
    end source file:

    begin perl script:
    #!c:\perl\bin\perl.exe -w
    use XML::DOM;
    use strict;

    &process_file( shift @ARGV );
    sub process_file {
    my $infile = shift;
    my $dom_parser = new XML::DOM::parser(NoExpand => 1,
    ProtocolEncoding => 'iso-8859-1', ParseParamEnt => 0, ExpandParamEnt
    => 0) ;
    my $doc = $dom_parser->parsefile( $infile ,NoExpand => 1,
    ParseParamEnt => 0, ExpandParamEnt => 0) ;
    print $doc->toString;
    $doc->dispose;
    }
    exit;
    end perl script:

    after: perl xml-dom-test.pl test.xml > test1.xml
    i have this

    begin target file:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <doc>
    <name>Mathias Wuendisch</name>
    </doc>
    end target file:

    i've read the sourceforge faq and i've found a solution for "named
    entities" like this:

    ---
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <!DOCTYPE doc [
    <!ENTITY nbsp " " >
    ]>
    <doc>
    <name>Mathias&nbsp;Wuendisch</name>
    </doc>
    ---

    ok, than the "named entity" &nbsp; is also in the target file... but
    what is with "unnamed entities" like &x#A0; ? why did the NoExpand
    flag or ExpandParamEnt flag not work for me? any suggestions?

    kind regards,
    mathias w&uuml;ndisch
     
    mathias wündisch, Jan 22, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tobi Krausl
    Replies:
    0
    Views:
    367
    Tobi Krausl
    Nov 18, 2003
  2. arne
    Replies:
    0
    Views:
    366
  3. Erik Wasser
    Replies:
    5
    Views:
    479
    Peter J. Holzer
    Mar 5, 2006
  4. Sean
    Replies:
    3
    Views:
    302
    robic0
    Oct 3, 2006
  5. Sean
    Replies:
    0
    Views:
    381
Loading...

Share This Page