Re: parsing xml file contents
- From: schlenk <schlenk@xxxxxxxxxxxxxxxx>
- Date: Mon, 14 Apr 2008 05:42:32 -0700 (PDT)
sreedhar wrote:
Hi All,
I am trying to write a script for parsing the xml content below:
package require tdom
set xml \
{<?xml version="1.0"?>
<CBI:PacketDataSummaryReport
xmlns:CBI="http://www.cablelabs.com/namespaces/CBI/2.0/xsd/CBI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cablelabs.com/namespaces/CBI/2.0/xsd/
CBI
http://www.cablelabs.com/namespaces/CBI/2.0/xsd/CBI-1.0.xsd">
<CBI:CaseIdentity>Bill-Kostka</CBI:CaseIdentity>
<CBI:IAPSystemIdentity>cmts-col1.mso.com</CBI:IAPSystemIdentity>
<CBI:TimeStamp>2007-04-06T17:16:34.000000Z</CBI:TimeStamp>
<CBI:AccessSessionId>5671986</CBI:AccessSessionId>
<CBI:PacketSignature>
<CBI:sourceAddress>23.45.32.12</CBI:sourceAddress>
<CBI:destAddress>197.200.1.45</CBI:destAddress>
<CBI:sourcePort>32456</CBI:sourcePort>
<CBI:destPort>80</CBI:destPort>
<CBI:protocol>6</CBI:protocol>
<CBI:NumPktsSinceLastReport>4564</CBI:NumPktsSinceLastReport>
</CBI:PacketSignature>
<CBI:PacketSignature>
<CBI:sourceAddress>197.200.1.45</CBI:sourceAddress>
<CBI:destAddress>23.45.32.12</CBI:destAddress>
<CBI:sourcePort>80</CBI:sourcePort>
<CBI:destPort>32456</CBI:destPort>
<CBI:protocol>6</CBI:protocol>
<CBI:NumPktsSinceLastReport>2855612</CBI:NumPktsSinceLastReport>
</CBI:PacketSignature>
</CBI:PacketDataSummaryReport>}
set doc [dom parse $xml]
set root [$doc documentElement]
After this if i want to select nodes how can i give path for getting
CBI:sourceAddress?
Can someone plz help me on this?
Also to some useful tutorials on tdom package.
See:
http://wiki.tcl.tk/1948
especially the example on that page "XPath Query with namespaces".
Michael
.
- References:
- parsing xml file contents
- From: sreedhar
- parsing xml file contents
- Prev by Date: parsing xml file contents
- Next by Date: ttk::treeview - just another idea...
- Previous by thread: parsing xml file contents
- Next by thread: ttk::treeview - just another idea...
- Index(es):
Relevant Pages
|