Saturday 15 September 2012

perl - XML::Simple's "XMLout" method is converting attributes to elements -


I am trying to use XML :: Simple to update some Java applications' server.xml files . When I'm able to fix and update the object, the output from XMLout is giving me some trouble It seems that emphasizing the importance of expanding all the basic features into single elements Ignore Java applications when they start.

Here is an example XML:

  & lt; Server port = "9000" shutdown = "shut down" & gt; & Lt; Service name = "Catalina" & gt; & Lt; Connector port = "9002" redirection = "8443" enabled lookup = "false" protocol = "AJP / 1.3" urencoding = "UTF-8" /> & Lt; Lister classname = "org.apache.catalina.core.AprLifecycleListener" at "SSLEngine =" /> & Lt; / Services & gt; & Lt; / Server & gt;   

I am making a small change through XMLin :

  $ xml- & gt; XMLin ("server.xml", ForceAre = & gt; ['Connector']); $ Server_xml- & gt; {'Port'} = $ server_port; $ Server_xml- & gt; {'Service'} - & gt; {'Connector'} - & gt; [0] - & gt; {'Port'} = $ http_port;   

Then I can output my file like this:

  XMLout ($ server_xml, RootName = & gt; 'server', KeepRoot = & Gt; 0, NoAttr = & gt; 1, Output file = & gt; "server.xml");   

Everything works fine and the data is good in the: Dumper, but when I look at my output, I now have XML like this:

  & lt; Server & gt; & Lt; Listener & gt; & Lt; SSLEngine & gt; On & lt; / SSLEngine & gt; & Lt; ClassName & gt; Org.apache.catalina.core.AprLifecycleListener & lt; / ClassName & gt; & Lt; / Listener & gt; ...   

I need everything that she backs up, but despite my best efforts it did not make me so far.

Post text "itemprop =" text ">

It is very hard to use XML :: Simple for input, but output is very close to impossible. I use. < / P>

  Use XML :: Libs ML Q (); My $ parser = XML :: Libacs ML- & gt; New (); my $ doc = $ parser-> parse_file ('server.xml '$ {Server- & gt; set attribute (port = & gt; $ server_port); $ $ for my $ connector ($ server) for my $ server ($ doc-> searchnode (' / server ')) - & gt; Search Node ('service / connector [0]') {$ a Ector- & gt; Setaetivet (port = & gt; $ http_port);}} $ doc- & gt; toFile ( 'server.xml');    

No comments:

Post a Comment