Altova Mailing List Archives
>microsoft.public.xsl Archive Home
>Thread Prev - How can I go about parsing this XML for the info I need?
>Thread Next - Re: How can I go about parsing this XML for the info I need?
Re: How can I go about parsing this XML for the info I need?
Date: 5/7/2009 6:06:00 PM
AlBruAn wrote: > Using code similar to the snippet I'm pasting below, I need to be able to > loop through the XML and retrieve specific pieces of information such as the > average counter_cpu_idle, the average counter_cpu_idle_states, etc. The file > includes multiple entries along the line of <data > xsi:type="ns2:perf_dataType">. > > Other information I needed from a different XML file was easy to navigate to > with simple XPath statements, but this looked like it requires XSLT...and I'm > not sure where to start. Any help would be greatly appreciated! Well XSLT helps if you want to transform your XML to another XML format or to HTML or to plain text and it uses XPath anyway to select and match nodes so I am not sure why you don't know where to start if you could deal with XPath for other documents. Which XPath API or XSLT processor (e.g. MSXML or .NET) do you want to use? XPaths are as simple as /packet/ns1:data/perf_mon/data[@xsi:type = 'ns2:perf_dataType'] then relative to that ns2:class[ns2:name = 'counters_vz_cpu']/ns2:instance/ns2:counter[ns2:name = 'counter_cpu_idle']/ns2:value/ns2:avg where you simply need to bind the prefixes used in the XML to the namespace URIs used in the XML. How you do that depends on the API you use/want to use so we need to establish that first before showing code how to do that. -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/