Solved

xml xmlns namespace and xsi_type extractions from xml using bash

Posted on 2013-05-14
4
406 Views
Last Modified: 2013-05-30
Greetings.
I need to know how to pull the values from XML header information:
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://www.accessdata.fda.gov/spl/schema/spl.xsd">

Open in new window


In addition, in several areas I have tags with xsi_type: attributes in it.  They do not show up in XPATH locations.  (ie. <tag xsi_type="CE" ... />

I am obligated to pull the xmlns, xmlns:xsi, xsi:schemaLocation and the specific tag (assuming I know the xpath to the tag) into a bash variable to do something with it.  Is this possible?

Thanks.
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://www.accessdata.fda.gov/spl/schema/spl.xsd">
   

Open in new window

0
Comment
Question by:Evan Cutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 39167652
which value in which header?
can you please give an example what to extract from where
0
 
LVL 9

Author Comment

by:Evan Cutler
ID: 39168120
I need all of them.
I need to put them into a variable in BASH so I can put it somewhere.

Thanks.
0
 
LVL 26

Accepted Solution

by:
wilcoxon earned 500 total points
ID: 39168719
xsi:type (it should be colon and not underscore) should show up in the XPath (given the right expression).  Are you sure it does not?

For parsing XML, you really want a true parser of some sort.  Since you reference XPath, I'm assuming you have access to one.  Otherwise, I would write a small script in Perl (or your language of choice) to extract the pieces you need.

That said, you can extract XML using regexes but it's tricky.
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39209504
Thanks for helping.  I am still looking for answers...but I appreciate the attempt.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question