[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] Skrive til en bestemt position i en fil i perl



Hip hip hurra, Spanien vandt!

Så fik jeg lige apt-get'et xml perl modulerne og prøvet koden af.
Modulet formaterer output'et dæsværre ikke så pænt.

Hans-Christian Stadler
-----------------------------
#!/usr/bin/perl

# Koded efter http://www.icewalkers.com/Perl/5.8.0/lib/XML/DOM.html

use strict;
use XML::DOM;

my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile("file.xml");

my @nodes = $doc->getElementsByTagName("ydertag");

my $yder_node = $nodes[0];
my $inder_node = $doc->createElement("indertag");
$yder_node->appendChild($inder_node);

my $egenskab_node = $doc->createElement("egenskab4");
$inder_node->appendChild($egenskab_node);

my $vaerdi_node = $doc->createTextNode("vaerdi 4");
$egenskab_node->appendChild($vaerdi_node);

$doc->printToFile ("file.xml");
$doc->dispose;



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 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] *