Solved

xml xmlns namespace and xsi_type extractions from xml using bash

Posted on 2013-05-14
4
403 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

762 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