I need to grab attributes from the XML file with pure bash script.
So I have the following XML file with a root element `Group` and lots of `Person` elements, every of them has `id` and `username` attributes. `id` is unique value for each element:
And I need to use bash script to extract the `id` and `username` attributes into some key-value structure:
Checked other related answers, but most of them suggest to use some XML parsers like xmllint. But unfortunately I do not have them on the target machine.
Can you kindly suggest what how I can achieve this. Thanks in advance.
I have an xml file:
<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Table1>
<Data1 10 </Data1>
<Data2 20 </Data2>
<Data3 40 </Data3>
<Table1>
</AutoData>
and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only.
I tried using sed... (10 Replies)
:confused:
Hello,
Is there any way to use the dir command / some DOS Script to select only first file of similar pattern of files in a direcotory and rename it for example, one directory has 5 files
abc_1005.txt
abc_5256.txt
abc_2001.txt
abc_2003.txt
abc_3006.txt
by use script I would... (2 Replies)
Hi,
Iam new to shell scripting.I have below urgent requirement
I want to read attributes (transaction,documentmode) in xml tag with shell scripting and create a filename with these attribues
Xml :
<PURCHASE_10 partner="food" version="1.50" timestamp="2009-03-10T09:56:55"... (3 Replies)
I am completely new to bash scripting and now need to write a bash script that would parse a XML file and take out values from specific tags.
I tried using xsltproc, xml_grep commands. But the issue is that the XML i am trying to parse is not UTF 8. so those commands are unable to parse my XML's... (4 Replies)
Hi guys,
I'm working on a large set of scripts to move files around several servers and manipulate them for our staff. Basically we're shooting things, the videos hit a server and then need organised due to the language they've been shot in. Our XML (designed for Apple's Final Cut Pro) is right... (6 Replies)
I need to extract all text delimited from <name> and </name> tags from an xml file, but not only first occurence. I need to extract all occurences.
I've tried with this command:
awk -F"<name>|</name>" 'NF>2{print $2}'
but it give only first occurence. How can i modify it? (18 Replies)
Hi ! I'm working into my first bash script to make some xml modification and it's going to make me crazy lol .. so I decide to try into this forum to take some ideas from people that really know about this!
This is my situation I've and xml file with a lots of positional values with another tags... (9 Replies)
I tried searching the forums, but couldn't find anything relevant to my question.
I have an xml file like the following:
<topLevel numberBlock="BLOCK1">
<item="content1" title="Content 1">
<RefPath="path/to/file1.txt />
</item>
<item"content2" title="Content 2" >... (4 Replies)
Hi All,
Hope all you are doing good! Need your help. I have an XML file which needs to be converted CSV file. I am not an expert of awk/sed so your help is highly appreciated!!
XML file looks like this:
<l:event dateTime="2013-03-13 07:15:54.713" layerName="OSB" processName="ABC"... (2 Replies)
I have multiple xml files where i want to update a subnode if the subnode project points to different project or insert a subnode if it doesn't exist using a xmlstarlet or any other command that can be used in a bash script.
I have been able to update the subnode project if it doesn't point to... (1 Reply)
Discussion started by: Sekhar419
1 Replies
LEARN ABOUT DEBIAN
xml::smart::dtd
XML::Smart::DTD(3pm) User Contributed Perl Documentation XML::Smart::DTD(3pm)NAME
XML::Smart::DTD - DTD parser for XML::Smart.
DESCRIPTION
This will parse DTD and provides methods to access the information stored in the DTD.
USAGE
use XML::Smart::DTD ;
my $dtd = XML::Smart::DTD->new('some.dtd') ;
if ( $dtd->child_exists('tag1','subtag1') ) {
...
}
use Data::Dumper ;
print Dumper( $dtd->tree ) ;
newMETHODS
attr_exists ( TAG , ATTR )
Return TRUE if the attribute exists in the element TAG.
child_exists ( TAG , CHILD )
Return TRUE if the child exists in the element TAG.
elem_exists ( TAG )
Return TRUE if the element TAG exists.
error
Return the error list.
get_attr_def ( TAG , ATTR )
Return the default value of an attribute
get_attr_type ( TAG , ATTR )
Return the attribute type.
get_attr_values ( TAG , ATTR )
Return the defined values of an attribute.
get_attrs ( TAG )
Return the attribute list of a element.
get_attrs_req ( TAG )
Return the required attribute list of a element.
get_childs ( TAG )
Return the child list of an element.
get_childs_req ( TAG )
Return the required child list of an element.
get_elem_opt ( TAG )
Return the occurrence option of an element:
! REQUIRED AND ONLY ONE MATCH
+ 1 or more
* 0 or more
? 0 or 1
get_elem_child_opt ( TAG , CHILD )
Same of get_elem_opt() but this element as a child of an element.
is_attr_fix ( TAG , ATTR )
Return TRUE if an attribute is FIXED.
is_attr_req ( TAG , ATTR )
Return TRUE if an attribute is REQUIRED.
is_elem_any ( TAG )
Return TRUE if an element is ANY.
is_elem_child_multi ( TAG , CHILD )
Return TRUE if an element can have multiple occurrences as a child of TAG.
is_elem_child_opt ( TAG , CHILD )
Return TRUE if an element is optional as a child of TAG.
is_elem_child_req ( TAG , CHILD )
Return TRUE if an element is optional as a child of TAG.
is_elem_child_uniq ( TAG , CHILD )
Return TRUE if an element is required and unique as a child of TAG.
is_elem_pcdata ( TAG )
Return TRUE if an element is PCDATA (have content).
is_elem_empty ( TAG )
Return TRUE if an element is EMPTY (doesn't have attributes, content or children).
is_elem_multi ( TAG )
Return TRUE if an element can have multiple occurrences globally.
is_elem_opt ( TAG )
Return TRUE if an element is optional globally.
is_elem_parent ( TAG , @PARENTS )
Return TRUE if the list of @PARENTS can be parent of element TAG.
is_elem_req
Return TRUE if an element is required globally.
is_elem_uniq
Return TRUE if an element is unique and required globally.
root
Return the root name of the DTD.
tree
Return the HASH tree of the DTD.
SEE ALSO
XML::Smart, XML::DTDParser.
AUTHOR
Graciliano M. P. <gm@virtuasites.com.br>
I will appreciate any type of feedback (include your opinions and/or suggestions). ;-P
THANKS
Thanks to Jenda@Krynicky.cz http://Jenda.Krynicky.cz that is the author of XML::DTDParser.
COPYRIGHT
The DTD parser was based on XML-DTDParser-1.7 by Jenda@Krynicky.cz http://Jenda.Krynicky.cz
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2004-09-01 XML::Smart::DTD(3pm)