[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] XML::LibXML og UTF-16



Så fandt jeg en workaround. Jeg synes ikke selv den er køn, men den
fungerer til det jeg skal bruge. 


#!/usr/bin/perl
use XML::LibXML;
my $doc = XML::LibXML::Document->new("1.0", "UTF-16");
my $root = XML::LibXML::Element->new("SJ_FESDpacket");
$root->setNamespace(undef, "sj", 1);
$root->setAttribute("xmlns:sj",
"http://rep.oio.dk/scanjour.dk/xml/schemas/2004/";);
$doc->setDocumentElement($root);
$doc->toFile("t.xml", 1);


Hvorfor synes jeg så ikke den er køn... Jeg ville jo egentlig mene at
jeg burde kunne bruge *NS funktionerne til at danne min XML. Jeg synes
heller ikke det er kønt hele tiden at gå tilbage til
XML::LibXML::Element for at få nye elementer. Tidligere har jeg bare
kunnet tage fat i Parent noden og bedt om et nyt element.


Jeg er stadig interesseret i at finde ud af hvorfor nedenstående ikke
umiddelbart kunne skiftest til UTF-16.


MVH Bjørn

On Tue, 2007-07-24 at 18:52 +0200, Bjørn Bille Højte wrote:
> Hej.
> 
> Jeg sidder med et lille problem, som jeg ikke umiddelbart kan
> gennemskue...
> 
> Følgende lille stump kode fungerer, og giver mig fint en "t.xml" fil:
> 
> #!/usr/bin/perl
> use XML::LibXML;
> my $doc = XML::LibXML->createDocument("1.0", "UTF-8");
> my $root = $doc->createElementNS("", "SJ_FESDpacket");
> $root->setNamespace(undef, "sj", 1);
> my $attr = $doc->createAttributeNS(undef, "xmlns:sj",
> "http://rep.oio.dk/scanjour.dk/xml/schemas/2004/";);
> $root->setAttributeNodeNS($attr);
> $doc->setDocumentElement($root);
> $doc->toFile("t.xml", 1);



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-08-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *