473,466 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Searching in lot of XML

m6s
55 New Member
Hello...

Can anyone help me on this, I have some xml and I want to find if an element, e.g. <BEER></BEER>
contains something (what ever) while those that are empty to skip.
I tried, the usual grep and fgrep or awk but as far as I got was to return every aspect of this element.

Thank you.
Mar 4 '08 #1
5 1490
radoulov
34 New Member
You need to provide a sample input and an example of the desired output.
Mar 4 '08 #2
m6s
55 New Member
You need to provide a sample input and an example of the desired output.
Expand|Select|Wrap|Line Numbers
  1. <ORDER>
  2. <BOX>1</BOX>
  3. <BEER>12</BEER>
  4. <WINE>15</WINE>
  5. <BEER></BEER>
  6. <WINE>ERROR</WINE>
  7. ...
  8. </ORDER>
  9.  
Sth like that XML, it's very simple...as data.
Mar 5 '08 #3
jeasoft
6 New Member
Excuse me for the question, but my english is not my best thing :P.

Do you need to search the element in the xml file?

If you want to search IN the file, you can you some editor and use some function to search on it.
For example, Gedit (ctrl + f to find), or VI (in command line, /xml ---> this search and show the results).

I ask excuses if this is not the right thing.
Mar 10 '08 #4
ghostdog74
511 Recognized Expert Contributor
only tested on your sample
Expand|Select|Wrap|Line Numbers
  1. awk '{n=gsub(/<BEER>|<\/BEER>/,""); if(n>0) print $0}' file
  2.  
Mar 10 '08 #5
m6s
55 New Member
only tested on your sample
Expand|Select|Wrap|Line Numbers
  1. awk '{n=gsub(/<BEER>|<\/BEER>/,""); if(n>0) print $0}' file
  2.  
Well...It worked..!!!
Can u give us some more details? What you wrote?

Thank u a lot!
Mar 12 '08 #6

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

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
18
by: jblazi | last post by:
I should like to search certain characters in a string and when they are found, I want to replace other characters in other strings that are at the same position (for a very simply mastermind game)...
4
by: tgiles | last post by:
Hi, all. Another bewildered newbie struggling with Python goodness. This time it's searching strings. The goal is to search a string for a value. The string is a variable I assigned the name...
2
by: Kakarot | last post by:
I'm gona be very honest here, I suck at programming, *especially* at C++. It's funny because I actually like the idea of programming ... normally what I like I'm atleast decent at. But C++ is a...
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
2
by: Bart Kastermans | last post by:
I have a file in which I am searching for the letter "i" (actually a bit more general than that, arbitrary regular expressions could occur) as long as it does not occur inside an expression that...
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
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...
1
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.