Solved

xml xmlns namespace and xsi_type extractions from xml using bash

Posted on 2013-05-14
4
402 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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
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…

832 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