473,770 Members | 5,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML::Simple question

Hi all,

I am working on perl..and am using XML::Simple to parse a xml document.
I've been trying to retrieve character data from tags whose occurance
is recursive.. The scenario can be better explained as below:

For a structure like,

<employees>
<employee>
<name>John Doe</name>
<age>43</age>
<sex>M</sex>
<department>Ope rations</department>
</employee>
</employees>

To access the value "John Doe", we can use the syntax:
$data->{employee}->[0]->{name} {$data is a XML::Simple variable}
But, how do I access the character data between the tags..when the tag
structure of the XML is as shown below..and tagging structure changes
with the document and is not standard, is there a function or
module..or technique..whic h works recursively..de pending on the nested
tagging structure of the XML document and retrieves the character data
located in the lowest level of the nesting?

How do the access all the data from this structure?

<outline>
<item>
<item>Protein s and Phospholipid Measurements</item>
<item>comprehen sion requirements</item>
</item>
<item>
<item>education al communication.</item>
<item>
<item>tradition al classroom.</item>
<item>peers around the world.</item>
</item>
</item>
</outline>
Jack

Jan 20 '06 #1
1 1238
You can use XPath (http://www.w3schools.com/xpath/default.asp) to
specify precise nodes.

Stephen

Jan 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2297
by: Paulo Pinto | last post by:
Hi, does anyone know of a Python package that is able to load XML like the XML::Simple Perl package does? For those that don't know it, this package maps the XML file to a dictionary.
8
6507
by: Dan | last post by:
Using XML::Simple in perl is extreemly slow to parse big XML files (can be up to 250M, taking ~1h). How can I increase my performance / reduce my memory usage? Is SAX the way forward?
0
1274
by: Randy | last post by:
Is there a dotnet class that formats XML simple types. I'm making a xmldocument which has a timestamp element (among others). The format is: yyyy-MM-ddThh:mm:ss (which looks like 2003-09-28T07:55:06). The schema looks like: <xsd:simpleType name="TimestampType"> <xsd:annotation> <xsd:documentation>Base typefor a date and time stamp</xsd:documentation> </xsd:annotation>
1
3428
by: Miguel Manso | last post by:
Hi there, I'm a Perl programmer trying to get into Python. I've been reading some documentation and I've choosed Python has being the "next step" to give. Can you point me out to Python solutions for: 1) Perl's Data::Dumper It dumps any perl variable to the stdout in a "readable" way.
2
1127
by: Ray5531 | last post by:
what is the equivalent of this in C# ? foreach (XmlNode xmlConfigNode in xmlConfigDoc.ChildNodes) Thansk
0
2137
by: Marv | last post by:
Is it possible to print the path of all leaf nodes of an XML using XML::Simple This is the kind of output text that i'm trying to print (not the leaf node values but the path to reach them) c:\> perl ListLeafs.pl config.xml {RootNode}->{ChildNode1}->{LeafNode1} {RootNode}->{ChildNode1}->{LeafNode2} {RootNode}->{ChildNode1}->{LeafNode3} {RootNode}->{ChildNode2}->{LeafNode1} {RootNode}->{ChildNode2}->{LeafNode2}
0
1421
by: JohnLucas | last post by:
Hi all, I have just started working with the XML::Simple module to parse an XML file. I'm trying to pull some values from the file that I need in another program. The problem is that the XML file is "nested" and I can't get the correct values out of the file. This is part of my xml file: <?xml version="1.0" encoding="ISO-8859-1"?> <Root>
4
3283
by: Steven M. O'Neill | last post by:
I have an xml structure like this: <Meta name="fieldAttributes"> <MetaString name="name">SUB_PHONE</MetaString> <MetaString name="value">999999999</MetaString> </Meta> <Meta name="fieldAttributes"> <MetaString name="name">SUB_NAME</MetaString> <MetaString name="value">XML PLUS</MetaString>
5
2584
by: 0xception | last post by:
Hi, I'm attempting to create a perl script that will modify a series of RRD databases (a couple hundred of them). in order to do this the RRD database can be exported to XML modified and then restored from XML. My issue is when using XML::Simple to read in and edit the xml structure and then output it back out the section of XML that was previously: <cdp_prep> <ds> ...
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.