473,484 Members | 1,631 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 1491
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
2510
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
2485
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
1792
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
8233
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
2341
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
2427
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
2380
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
2603
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
3163
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
1500
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...
0
7082
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
7105
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
7144
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
6813
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...
1
4845
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
4529
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...
0
3046
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
3041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
235
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.