Help with xmllint


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with xmllint
# 1  
Old 05-23-2015
Help with xmllint

Have like 50 xml files in a folder. They all have a Node named <Number>.How to display the values of <Number> with the count and filename in the folder. I am using Mac .

Last edited by Anethar; 05-24-2015 at 02:09 PM..
# 2  
Old 05-24-2015
Hi, welcome to these forums. Please show a representative sample of input, desired output and attempts at a solution and specify what OS and versions are being used.

And please post in the right forum..
# 3  
Old 05-24-2015
Thanks. Eg: The file emp1.xml

Code:
<Employee>
    <EmployeeId>1</ EmployeeId >
    <DeptId>E</DeptId>
    <InternId>94</internId>
     <Number>10<Number>

There will 50 xml files or more than that .
How to write an xmllint or any command to display the value of <Number> and its filename?

I wrote :
Code:
xmllint --xpath "//Number" *.Xml

.

is it right?

Then : sometimes <Number xsi:nil="true">.

How to write an xmllint or any other command to find <Number> is true or NULL value.
since its more than 50 files and it might increase in future pl let me know and thanks

Computer : Mac
OSX :10.9.2
Terminal in Mac.

Last edited by Anethar; 05-24-2015 at 04:58 PM.. Reason: Add CODE and ICODE tags.
# 4  
Old 05-25-2015
Instead of using xmllint, and providing your XML file layout is consistent, you could do something like this:
Code:
$ grep -E "<Number>(.*)</Number>" *.xml | sed -e 's/<Number>\([^<]*\)<\/Number>.*/ \1/g'

# 5  
Old 05-25-2015
Typed the command. Displays or returns back to the $ mode without any result. Pl help.

---------- Post updated at 06:25 PM ---------- Previous update was at 04:54 PM ----------

I tried the below :

Code:
xmllint --xpath "//Number[contains(name, “true”)] *.Xml

returns the 50 files output , with the values of the <Number> and the filename.

But I need to print the <Number> which has value :

Code:
<Number xsi:nil="true"/>

Pl help.Thanks.

Last edited by Don Cragun; 05-25-2015 at 07:55 PM.. Reason: Add missing ICODE tags; change HTML tags to CODE tags.
# 6  
Old 05-25-2015
Your request is not at all clear.

Please post a couple of small XML files (in CODE tags) and show us exactly what you are hoping to get as output (in CODE tags) from those sample files.

In XML files, tags aren't values, values come between opening tags and closing tags; or XML tags contain attributes that have values. Are you trying to get the value of the nil attributes in Number tags in your XML files?
# 7  
Old 05-26-2015
Yes.

Trying to get the value of the
HTML Code:
nil
attributes in
HTML Code:
<Number>
tags in XML files.

Thanks for the help.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Xmllint parser error : EntityRef: expecting ';'

Hi I have an XML file which contains html urls in that node values. When i use xmllint to parse that, i am getting error (because of the sympols in the url). i have used --html option but it throws other tag errors. Please guide me. sample file.xml <abc> <bcd> <cde> <a>sometext</a>... (2 Replies)
Discussion started by: ananan
2 Replies

2. Shell Programming and Scripting

Xmllint: get one result per line

Hi, I'm trying to get some values from an xmlfile and want be able to process them. I'm using xmllint(v20901 on debian jessie) and this program directly outputs all results concatenated right after each other. I did not find a solution in the man page to get a different format or some output... (2 Replies)
Discussion started by: stomp
2 Replies

3. Shell Programming and Scripting

Parse XML using xmllint

Hi All, Need help to parse the xml file in shell script using xmllint. Below is the sample xml file. <CARS> <AUDI> <Speed="45"/> <speed="55"/> <speed="75"/> <speed="95"/> </AUDI> <BMW> <Speed="30"/> <speed="75"/> <speed="120"/> <speed="135"/> </BMW>... (6 Replies)
Discussion started by: prasanna2166
6 Replies

4. Shell Programming and Scripting

Linux xmllint schema validation fails but error code 0

Command line xmllint --schema validation fails but $? returns 0 myinput.xml: <myinput><header>mytestvalue</header></myinput>myschema.xsd <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="myinput" type="xsd:string"/> </xsd:schema>Command: $xmllint --schema... (4 Replies)
Discussion started by: mknag
4 Replies

5. Shell Programming and Scripting

Xmllint - Xml-file problem --ods file not opening

Dear All, this is my first post on this Forum, glad to be here. I'm trying to fix an .ods file. Yes, I had a backup, but it's also corrupted. When opening the document I get this EM: read error format error discovered in the file in sub-document content.xml at 2,337040(row,col). So I... (3 Replies)
Discussion started by: jameslast
3 Replies

6. UNIX for Dummies Questions & Answers

Xmllint pretty print, batch files

I have about 20 xml files I want to use xmllint to pretty print: xmllint --format file01.xml > pretty_file01.xml xmllint --format file02.xml > pretty_file02.xml etc Is there a way I can just use "xmllint --format" on all the current xml files so I don't have to run this command 20 times?? :( (5 Replies)
Discussion started by: pxalpine
5 Replies

7. Shell Programming and Scripting

XMLLINT COMMAND IN UNIX TO VALIDATE XML AGAINST XSD

Hi i am baby to unix shell script. how do i validate xml agaist xsd and transforms xml using xslt. Thanks Mohan (2 Replies)
Discussion started by: mohan.cheepu
2 Replies

8. Shell Programming and Scripting

xmllint output to a file

Hello All, I have an XML file which has some errors in its tag definition according to an xsd. When i validate this xml file against an xsd, i wish to only take the errors in a file and not the complete xml. for eg. Raman.xml has some errors induced in it. RamanValidator.xsd holds the schema... (5 Replies)
Discussion started by: damansingh
5 Replies

9. UNIX for Advanced & Expert Users

iconv and xmllint

Here is my question, volume of records processed : 5M ( approx ) Its basically very simple operation that am trying to do and I had achieved the output that am interested. What am looking for really is to improve the performance, an optimized way to do that. with respect to iconv, am... (3 Replies)
Discussion started by: matrixmadhan
3 Replies
Login or Register to Ask a Question