I have a file like:
which I was using awk to parse <toponymName> of Palos Verdes, but that's 2 words, which is 2 fields, so I am trying to update my code to use xmlstarlet, so far here's what I have:
and I get the error:
I'm not clear what the role of a template is, is this some class I have to call up, does it already exist, or do you have to make one for each style of xml file?
---------- Post updated at 11:52 AM ---------- Previous update was at 11:47 AM ----------
Here's some examples for xmlstarlet. The -t option is mandatory for this, though it doesn't need a file, apparently the 'sel' options and the like are specifying a template themselves.
I moved the -m tag to match my "city" term, still no joy. I'm still trying to understand the context of when you do/don't need a template, and if there already existing "classes" of templates I can call up?
My understanding of this is limited as well, but as I get it so far, the options you're specifying are the template. You can also give it a template stored in a file.
1. sel - that's what you want if you want to query something from your xml file
2. -t - the template is that you specify something you want to match, which is why you have -m next
3. -m - that's the match part, what you want to match, or try to find. In order to match something, you have to know something about the structure of your xml file, to tell xmlstarlet where to go looking. In my case, it had to start looking in the element <geoname>, since that's where the child element I want lives. You can find out your structure by running xmlstarlet el xmlfile, that will tell you the element structure without the gobblygook.
4. -v - this is what you're actually searching for, in my case what's in the child element <toponymName>
5. file - your source xml file
Feel free to correct me if any of this is wrong, just trying to learn and then simplify it for the next guy
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)
Hi,
I have hit a bit of a brick wall.:confused:
need the following code edited:
echo "<?xml version=\"1.0\"?><dailyBalance_ROWSET>" > ${DataDir}/${extract_script}${ApplicationDate}.${Suffix}
RunSQL ${extract_script} ${ActionFlag}
echo "</dailyBalance_ROWSET>" >>... (2 Replies)
Dear All,
I have a template xml file like below.
....Some---Header.......
<SignalPreference>
...
<SignalName>STRING</SignalName>
...
</SignalPreference>
......Some formatting text.......
<SignalPreference>
.........
... (3 Replies)
I'm parsing around 600K xml files, with roughly 1500 lines of text in each, some of the lines include Chinese, Russian, whatever language, with a bash script that uses
cat $i | xmlstarlet sel -t -m "//section1/section2/section3/section4/section5" -v "@VALUE" -n > somefile
which works, but I... (15 Replies)
I have a xmlfile like this:
<?xml version="1.0" encoding="utf-8"?>
<contentlocation xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="http://wherein.yahooapis.com/v1/schema" xml:lang="en">
<processingTime>0.001538</processingTime>
... (1 Reply)
Hi,
I have the following file
Example.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<html><set label="09/07/29" value="1241.90"/>
</html>
Can any one help me in parsing this xml file
I want to retrive the attribute values of the tag set
Example I want to... (3 Replies)
How can I parse file containing xml ?
I am sure that its best to use perl - but my perl is not very good - can someone help?
Example below contents of file containing the xml - I basically want to parse the file and have each field contained in a variable..
ie. I want to store the account... (14 Replies)
Hi,
I need to parse the following XML data enclosed in <a> </a> XML tag using shell script.
<X>
.....
</X>
<a>
<b>
<c>data1</c>
<c>data2</c>
</b>
<d>
<c>data3</c>
</d>
</a>
<XX>
...
</XX> (5 Replies)
I need to know the way. I have got parsing down some nodes. But I was unable to get the child node perfectly. If you have code please send it. It will be very useful for me. (0 Replies)