The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
get rid of xml comment by grep or sed RonLii Shell Programming and Scripting 3 05-22-2009 12:10 AM
comment text in a file learnbash Shell Programming and Scripting 8 04-11-2009 03:36 PM
Pls comment on my script. sparcguy Shell Programming and Scripting 3 11-21-2008 04:18 AM
How to copy and comment out upsrk Shell Programming and Scripting 3 06-19-2008 11:01 AM
# comment rocker40 UNIX for Dummies Questions & Answers 6 01-07-2004 12:53 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-02-2009
J-Hon J-Hon is offline
Registered User
  
 

Join Date: Jun 2009
Location: NKY
Posts: 2
Help using SED to comment XML elements

I'm trying to write a script to help automate some VERY tedious manual tasks.

I have groups of fairly large XML files (~3mb+) that I need to edit.

I need to look through the files and parse the XML looking for a certain flag contained in a field. If I find this flag (an integer value) I need to insert XML comments around the entire element (in the <!-- --> style) so that another XML parser will skip over them. After doing that, I later need to remove all the comments from the file (which I think I have).

I found this thread:
commenting xml file lines

Which explains how to insert the comments using SED based on finding the element tag in the file. This is helpful, but I only need to comment elements that contain the "flag" (an int value). Unfortunately, the elements have various names, and aren't in any sort of order.

I was thinking about using PHP (what I'm most familiar with) or maybe Ruby to help parse through the XML to find matching flags, which I'm comfortable with. My problem is how to use/invoke SED once I find a element that needs commenting, and doing so.

This might be something easy, but at the moment I'm having a hard time figuring out which direction to go in. Does anyone have any guidance they'd share with me? Does it sound like I'm heading in the right direction, or am I totally off? Am I overlooking some obvious answer?

I'd much appreciate any help.

- Jeremy
 

Bookmarks

Tags
comment, sed, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0