473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get same input xml file as xml out file

i am trying to update xml element value using XML::Simple::XMLin .But when I am again trying to retrive the XML data as it was before using XML::Simple::XMLout.
But finding a deviation in the format can any pls help me out with same xml file structure.

input file:
Expand|Select|Wrap|Line Numbers
  1. <NavigationMap> <PageLink> <LinkText/> <url>/ae/index.html</url> <Domain>//www.fedex.com</Domain> <Protocol>UnSecure</Protocol> <Target/> <LinkParams/> </PageLink> <ImageSource alt="FedEx Home">//images.fedex.com/images/c/t1/gh/logo-header-fedex-express.png</ImageSource> </Logo> </NavigationMap>
  2.  
Output file after execute:
Expand|Select|Wrap|Line Numbers
  1. <NavigationMap lastId="146"> <Logo> <ImageSource alt="FedEx Home">//images.fedex.com/images/c/t1/gh/logo-header-fedex-express.png</ImageSource> <PageLink> <Domain>//www.fedex.com</Domain> <LinkParams></LinkParams> <LinkText></LinkText> <Protocol>UnSecure</Protocol> <Target></Target> <url>/zw/index.html</url> </PageLink> </Logo> </NavigationMap>
  2.  
Perl code:
Expand|Select|Wrap|Line Numbers
  1. $data = $xml -> parse_file($file_in,ForceArray => 1,KeyAttr =>[]);
  2. foreach $TabEle (@{$data->{Logo}}) # retrieving list of values under Tab element
  3. {
  4.         foreach $NameEle (@{$TabEle->{PageLink}}){
  5.         foreach $LinktxtEle(@{$NameEle->{Protocol}}){
  6.         print $LinktxtEle;
  7.         }
  8.  
  9.    }
  10.  }
  11. XMLout($data,rootname => 'NavigationMap',KeyAttr =>[],OutputFile => $file_in,NoSort => 1);    #Writing xml back with updated value.
  12. }
  13.  
Expected result:
Expand|Select|Wrap|Line Numbers
  1. <NavigationMap lastId="146"> <PageLink> <LinkText/> <url>/ae/index.html</url> <Domain>//www.fedex.com</Domain> <Protocol>UnSecure</Protocol> <Target/> <LinkParams/> </PageLink> <ImageSource alt="FedEx Home">//images.fedex.com/images/c/t1/gh/logo-header-fedex-express.png</ImageSource> </Logo> </NavigationMap>
Jan 14 '15 #1
1 1609
RonB
589 Expert Mod 512MB
The author of the module states:
STATUS OF THIS MODULE

The use of this module in new code is discouraged. Other modules are available which provide more straightforward and consistent interfaces. In particular, XML::LibXML is highly recommended.

The major problems with this module are the large number of options and the arbitrary ways in which these options interact - often with unexpected results.

Patches with bug fixes and documentation fixes are welcome, but new features are unlikely to be added.
Jan 14 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joel Goldstick | last post by:
I wanted to write a simple page to let me choose a directory and then list the files in it. The end goal was to make an easy way to copy all the file names in a directory. I tested with Opera7,...
3
by: Maris Janis Vasilevskis | last post by:
Hi, I create a binary file on client side using ActiveX. Now, I need to upload it. First idea - hidden Input type=file Does not work, because value is read only. A quickly made working...
3
by: oopaevah | last post by:
I want to have a separate button which invokes the "browse" button on an input type=file. In internet explorer the following code works ok, in firefox nothing happens. All I do is call click()...
5
by: hrpreet | last post by:
Hi All, I need the file chooser in the jsp, just for brosing and saving the file path in the database, so i have used the following code.I dont need to read the file content. I have to make it...
9
by: Prakash Singh Bhakuni | last post by:
am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening...
0
by: ThunderMusic | last post by:
Hi, I have a page where I have an input type=file control and many other controls... the thing is, when I cause a postback by any control on the page, if a file is selected in the input...
12
by: Larry Bud | last post by:
I rarely crosspost, but this affects both ASP and Javascript REALLY odd bug that I ran across in ASP 3.0. I have an input type of file, user clicks browse, then places his cursor in the...
8
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.