473,394 Members | 1,778 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.

XML Parsing - Finding a particular node

I am working on a university masters project. It involves extracting information from xml files. The xml file consists of information as shown below.

<Moved to attachment - MOD>

I have to write a code, so that whenever the user enters the node_id, the information about that node gets retrieved, in xml format.

I have been trying many approaches, but to no avail. Please help me out on it, as I am nearing the deadline. Please.

Thanks..
Attached Files
File Type: txt nodexml.txt (4.1 KB, 409 views)
Jul 21 '07 #1
4 1510
numberwhun
3,509 Expert Mod 2GB
First, nice user name.

Writing code isn't all that bad and we can certainly do our best to help you. Why not post what you have tried thus far and we can help you achieve your goal and point you in the right direction.

Regards,

Jeff
Jul 21 '07 #2
Thanks for the reply, Jeff. Here's what I had done.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. $node=<STDIN>;
  7. chomp($node);
  8.  
  9. my @nodeinfo = ( );
  10.  
  11. open (NODEINFO,"C:\\test.xml") || die "cannot open nodefile: $!\n";
  12.  
  13. my @nodeinfo = <NODEINFO>;
  14.  
  15. close NODEINFO;
  16.  
  17. foreach $nodeid(@nodeinfo) {
  18.     if ($nodeid =~ /<node_id (.*) <\ /node>/) {
  19.         print $nodeid;
  20.     }
  21. }
  22.  
I am basically from biology field, but trying to grasp perl for this part of my project. I have tried out many similar programs after looking out in various books.

By the way, I have now got one day less for my deadline.
Jul 22 '07 #3
numberwhun
3,509 Expert Mod 2GB
I have not, unfortunately, played with any of the XML modules to any extent, but you may want to look at this page. That is the page for the XML::Simple module. It describes right in the beginning how you can use this module to slurp in the XML, and then Data::Dumper to more easily get at the information contained within each set of elements.

Hopefully this will get you pointed in the right direction. I also hope that some of the others that have dealt with XML will throw some advice you way as well, if they have a minute.

Regards,

Jeff
Jul 22 '07 #4
Thanks a lot Jeff!!!

The XML::Simple works beautifully in reading the xml into hash, but I am still finding problem with extracting information about one particular node.
Any help, or suggestions are welcome.

Thank you
Jul 24 '07 #5

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

Similar topics

0
by: Udo Giacomozzi | last post by:
Hello, I want to parse a UAProfile XML file to know the capabilities of the clients WAP cellular phone. Has anybody already written some PHP code that does this? Anyway, I haven't done...
0
by: Yang Xiao | last post by:
Hi all, I'm having some problems with parsing XML with DOMParser. What I want is to filter out particular elements in the XML, the sample XML looks like this. Thanks in advance. Yang ...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
6
by: Thomas Polan | last post by:
Sorry if this has been posted before... I am receiving XML messages over a TCP client. Messages vary in size and sometimes can arrive in groups. Thus, I am not guaranteed to receive a full...
6
by: Jay Bienvenu | last post by:
I have the following Visual Basic .NET code in an ASP.NET project: ' ... Dim xdStructure As XmlDocument Dim xnStructureRoot As XmlNode xdStructure = New XmlDocument...
8
by: Fabio Cannizzo | last post by:
I have an XML file based on an XSD schema. It represents the content of a treeview (or a menu system), where the nodes are always of the same few types, but can be arbitrarily nested. I am...
3
by: Hilton Lima | last post by:
Hi there; I have the following problem. I am using one of the many javascript XML parsing scripts available around the Internet, but the parsing fails when it reach an XML child node that is...
5
by: WTH | last post by:
In C++ I had, long ago, written my own XML parsing class as I never found even a half decent node based hierarchical solution that was simple, now that I'm starting to develop tools in C# (as a...
2
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.