Sponsored Content
Full Discussion: XML Problem
Top Forums Shell Programming and Scripting XML Problem Post 302201959 by Zarnick on Tuesday 3rd of June 2008 02:07:19 PM
Old 06-03-2008
XML Problem

Hello, I need a script to edit a custom XML, although I know it should be fairly easy to create such a script, I'm failing miserably.
The script should be able to read from a file containing the ids of one tag of the xml (<content contentid="XXX".... for example) and then remove this content.
For instance, for the simple XML file like this:
Code:
<categorygroup categorygroupid="test">
 <category categoryid="test_category1">
  <content contentid="0001" name="content_test">
  ...
  </content>
  <content contentid="0002" name="content_test2">
  ...
  </content>
  <content contentid="0003" name="content_test3">
  ...
  </content>
 </category>
 <categorygroup categorygroupid="test">
 <category categoryid="test_category2">
  <content contentid="0011" name="content_test1">
  ...
  </content>
  <content contentid="0012" name="content_test12">
  ...
  </content>
  <content contentid="0013" name="content_test13">
  ...
  </content>
 </category>
</categorygroup>

If one has the codes 0001, 0012 and 0013 on the file, it should become this xml file:
Code:
<categorygroup categorygroupid="test">
 <category categoryid="test_category1">
  <content contentid="0002" name="content_test2">
  ...
  </content>
  <content contentid="0003" name="content_test3">
  ...
  </content>
 </category>
 <categorygroup categorygroupid="test">
 <category categoryid="test_category2">
  <content contentid="0011" name="content_test1">
  ...
  </content>
 </category>
</categorygroup>

Now, I'm pretty sure this should be easy, but I'm having a VERY big amount of trouble by doing this (I've tried PERL, Ruby, PHP and even sed with grep) can anyone help me?

Thanks.
 

10 More Discussions You Might Find Interesting

1. Programming

importing xml: problem

I'm an absolute newbie for unix... For my work, I have to import a xml file in our system (jsp+sql) via putty telnet. Once i have copied the file in the right directory, I launch this command: ./thisImport -i input/thisImport/newimport.20071130.xml -l 10 -t this is a test (as you can see),... (1 Reply)
Discussion started by: tranky
1 Replies

2. Shell Programming and Scripting

Problem printing the property of xml file via shell script

Hi, I have a config.xml which cointains the tags like <CONFIG> <PROPERTY name="port" value="1111"/> <PROPERTY name="dbname" value="ABCDE"/> <PROPERTY name="connectstring" value="xyz/pwd"/> </CONFIG> This file is in some directory at UNix box. I need to write a... (4 Replies)
Discussion started by: neeto
4 Replies

3. Shell Programming and Scripting

XML Copy & replace problem

I probably could have done this at one time, but, the years and no need has left my scripting skills lacking and I'm unable to work this problem out. https://www.unix.com/images/smilies/frown.gif :( Using Linux, have a great many xml files in which there may be multiple occurrence of a line of... (13 Replies)
Discussion started by: xenixuser
13 Replies

4. Shell Programming and Scripting

Perl - problem with CPAN module XML::Simple

Hi All, I am trying to run the following program #!/usr/bin/perl # use module use XML::Simple; use Data::Dumper; # create object $xml = new XML::Simple; # read XML file $data = $xml->XMLin("dump.xml"); # print output print Dumper($dump); At first i had the error mesage saying... (5 Replies)
Discussion started by: userscript
5 Replies

5. Shell Programming and Scripting

Facing problem in XML::parser module in PERL

HI, I have XML file which is having values as Spanish character (UTF-8 encoding). I am using XML::parser module but my code is not able to read those characters. I did goggling but not able to find suitable solution. Anybody please help me out. XML file having characters like: ñ I am... (1 Reply)
Discussion started by: jatanig
1 Replies

6. Shell Programming and Scripting

Cygwin vi XML file encoding problem

Hi, I have got a zip (binary) file transferred from MacOS (thus it has additional __MACOSX directory packed inside). On extracting this zip, there are few *.xml files available. When I opened this *.xml file in vim editor using Cygwin (on windows) the editor displayed in the bottom. I tried... (4 Replies)
Discussion started by: royalibrahim
4 Replies

7. Shell Programming and Scripting

xml extract problem

I have looked at other responses and never was able to modify to work. data is: <?xml version="1.0"?> <note version="0.3" xmlns:link="http://beatniksoftware.com/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size" xmlns="http://beatniksoftware.com/tomboy"><title>recoll</title><text... (12 Replies)
Discussion started by: Klasform
12 Replies

8. Programming

problem with accessing online XML file

Hi everyone, I am trying to access an online XML file, for example: <a href="http://www.rgraph.net/sample.xml" target="_blank">http://www.rgraph.net/sample.xml using HTML. <html> <body> <script type="text/javascript"> if (window.XMLHttpRequest) {// code for IE7+, Firefox,... (1 Reply)
Discussion started by: Xperia124
1 Replies

9. Shell Programming and Scripting

How to add the multiple lines of xml tags before a particular xml tag in a file

Hi All, I'm stuck with adding multiple lines(irrespective of line number) to a file before a particular xml tag. Please help me. <A>testing_Location</A> <value>LA</value> <zone>US</zone> <B>Region</B> <value>Russia</value> <zone>Washington</zone> <C>Country</C>... (0 Replies)
Discussion started by: mjavalkar
0 Replies

10. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies
XML::LibXML::RegExp(3)					User Contributed Perl Documentation				    XML::LibXML::RegExp(3)

NAME
XML::LibXML::RegExp - XML::LibXML::RegExp - interface to libxml2 regular expressions SYNOPSIS
use XML::LibXML; my $compiled_re = new XML::LibXML::RegExp('[0-9]{5}(-[0-9]{4})?'); if ($compiled_re->isDeterministic()) { ... } if ($compiled_re->matches($string)) { ... } $compiled_re = XML::LibXML::RegExp->new( $regexp_str ); $bool = $compiled_re->matches($string); $bool = $compiled_re->isDeterministic(); DESCRIPTION
This is a perl interface to libxml2's implementation of regular expressions, which are used e.g. for validation of XML Schema simple types (pattern facet). new() $compiled_re = XML::LibXML::RegExp->new( $regexp_str ); The constructor takes a string containing a regular expression and returns a compiled regexp object. matches($string) $bool = $compiled_re->matches($string); Given a string value, returns a true value if the value is matched by the compiled regular expression. isDeterministic() $bool = $compiled_re->isDeterministic(); Returns a true value if the regular expression is deterministic; returns false otherwise. (See the definition of determinism in the XML spec (http://www.w3.org/TR/REC-xml/#determinism <http://www.w3.org/TR/REC-xml/#determinism>)) AUTHORS
Matt Sergeant, Christian Glahn, Petr Pajas VERSION
1.70 COPYRIGHT
2001-2007, AxKit.com Ltd. 2002-2006, Christian Glahn. 2006-2009, Petr Pajas. perl v5.12.1 2009-10-07 XML::LibXML::RegExp(3)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy