473,394 Members | 1,875 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,394 software developers and data experts.

Is there any possible way to convert XML::Twig object to XML::XPath object

I'm using XML::XPath for a long time to parse xml, now the situation has come to modify the attribute value.

xml is available in a file, it will be very similar to this.

<AppName>
<Action AllDay='1' StartRace='1'/>
<StartPoint AM_PM='AM' Hours='09' Mins='30'/>
<EndPoint AM_PM='PM' Hours='06' Mins='30'/>
</AppName>

I have written a perl script to change the Hours of StartPoint tag,

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use XML::Twig;
  4.  
  5. my $fileName = 'Conf.xml'
  6.  
  7. my $twig = XML::Twig->new(
  8.     twig_roots => { StartPoint => \&ReplaceAtriValue },
  9.     twig_print_outside_roots => 1,
  10. );
  11.  
  12. sub ReplaceAtriValue {
  13.     my ($twig, $startPoint) = @_;
  14.     if ( '09' eq $startPoint->att('Hours') )
  15.     {
  16.         $startPoint->set_att( Hours => '12');
  17.     }
  18.     $startPoint->print();
  19. }
  20. $twig->parsefile($fileName);
Now $twig has the xml object. If I send this object($twig) to my SetWindow.pm which parse xml using XML::XPath, did not recognize this object. Is there any possible way to convert XML::Twig object to XML::XPath object so that XML::XPath will parse values in the $twig object.

Actually I have using XML::XPath for long back hence I have to send the XML::XPath object to all my own *.pm like SetWindow.pm, at the same time i need to change the values of the attribute of the standard xml before sending to my own PMs.

Thanks in Advance
Any Help is much appreciated
Oct 19 '11 #1
0 1297

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

Similar topics

1
by: Robert Oschler | last post by:
With PHP 4, is there a way to convert an associative array to an object? For example, suppose I have the following arrays inside a nested associative array ($nestedAA): $AA1 = 'fieldValue1'; ...
4
by: Xenia | last post by:
Hello! Is anyone can help me to figure out how to write some xml into huge xml file into speceific location??? Say, i have a file about 139 Mb and i need to write some data (xml) into it, but...
2
by: user | last post by:
Hi How do i remove comments from a DOM object ? I tried searching the man pages XML::DOM, XML::DOM::Comment and XML::DOM::Document but could not find anything The code used to parse the...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: Grant Harmeyer | last post by:
I am attempting to construct a simple ASP.NET Rss/Xml newsfeed. If anyone has visited Don Box's Blog (http://www.gotdotnet.com/team/dbox/), you will notice that his Rss feed is exposed through an...
1
by: Ricardo Quintanilla | last post by:
Using Xml Serialization to serialize an object, how can i take control over the finall Xml Encoding? I mean, when i serialize an object, i always get something like that == == == <?xml...
2
by: Frank | last post by:
Hi All, I've been yanking my hair out all day over this one, and finally decided to grab some sample code from MSDN, only to find the exact same problem What's the problem? The problem is...
5
by: JoeP | last post by:
Hi All, Is that possible to convert an Exception object to SMTPException object. I tried CType() and it did not work! Thanks,
5
by: rcronk | last post by:
I'm new to C#/.NET. I am writing some C#/.NET (2.0) classes that will allow someone to get and set values in an XML file using an XPath to point to the location of that data. It's more complicated...
2
!NoItAll
by: !NoItAll | last post by:
I am loading an xml document into a vb.net webbrowser object. I can not figure out how to get the xml out of it though. Basically I am going to a URL that has an xml document. It loads just...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.