1
votes

I have an issue with the setData method of libXML in perl. Here is my code snippet:

    print "\n Query: " , $query, "\n";  #Query
    my($exactNode) = $doc->findnodes($query);  #Finding the nodes who data needs to change
    print "\n Data: ", $exactNode->setData($finalString), "\n";  #Setting the data

After using the setData I used getData to retrieve the value. The value outputted by getData is the latest one but when I open the xml where this data should be set. The value is the old.

Please advise what am I doing wrong.

1

1 Answers

3
votes

I'm not too familiar with LibXML, but setData is documented to return nothing. You probably have to call setData() and then retrieve it separately.

I also do not believe the LibXML will save changes for you. You likely have to explicitly save the modified XML document, probably with toFile. See XML::LibXML::Document.