all groups > dotnet xml > august 2005 >
You're in the

dotnet xml

group:

need help with xpath query


need help with xpath query Scott.Emick NO[at]SPAM gmail.com
8/29/2005 6:54:04 AM
dotnet xml: In the following XML example I am trying to grab the element that
contains the exchange rate (frbny:OBS_VALUE) using SelectSingleNode &
an expath expression, but none of the ones I've tried seem to work.
Any suggestions? (I'm using VB .Net 2003)

Thanks,
Scott Emick


<?xml version="1.0"?><UtilityData
xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/message
http://www.sdmx.org/data/SDMXMessage.xsd
http://www.newyorkfed.org/xml/schemas/FX/utility
http://www.newyorkfed.org/xml/schemas/FX_Utility.xsd"
xmlns:generic="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/generic"
xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/message"
xmlns:utility="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/utility"
xmlns:query="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/query"
xmlns:structure="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/structure"
xmlns:common="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/common"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:compact="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/compact"
xmlns:frbny="http://www.newyorkfed.org/xml/schemas/FX/utility"
xmlns:cross="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/cross"><Header><ID>FX12CA</ID><Test>false</Test><Name
xml:lang="en">Foreign Exch
ange Canada Dollar Noon
Rates</Name><Prepared>2005-08-29</Prepared><Sender id="FRBNY"><Name
xml:lang="en">Federal Reserve Bank of New York</Name><Contact><Name
xml:lang="en">George
Matthes</Name><Email>george.matthes@ny.frb.org</Email></Contact></Sender><ReportingBegin>1994-01-06</ReportingBegin></Header><frbny:DataSet><frbny:Series
AVAILABILITY="A" DECIMALS="4" UNIT_MULT="0" TIME_FORMAT="P1D"
UNIT="USD" FX_METHOD="12" DISCLAIMER="12"
AUTHORITY="12"><frbny:Key><frbny:FREQ>D</frbny:FREQ><frbny:CURR>CAD</frbny:CURR><frbny:FX_TIME>12</frbny:FX_TIME><frbny:FX_TYPE>S</frbny:FX_TYPE></frbny:Key><frbny:Obs
OBS_STATUS="A"
OBS_CONF="F"><frbny:TIME_PERIOD>2005-08-26</frbny:TIME_PERIOD><frbny:OBS_VALUE>1.1949</frbny:OBS_VALUE></frbny:Obs></frbny:Series></frbny:DataSet></UtilityData>
Re: need help with xpath query Scott Emick
8/29/2005 7:06:32 AM
I can access the data heirarchically by:

("UtilityData")("frbny:DataSet")("frbny:Series")("frbny:Obs")("frbny:OBS_VALUE")

but it would look nice with an xpath query.

Scott
Re: need help with xpath query danprime
9/7/2005 9:51:41 AM

[quoted text, click to view]
What have you tried?

You may want to take a look at this free utility called XPat
Visualizer. http://www.topxml.com/xpathvisualizer/
You can use it to help you nail down your XPath queries.

For a very basic test, why not try:
//frny:OBS_VALUE ?

If you're working with C# make sure you set up and pass
XMLNamespaceManager as well when executing your SelectSingleNode.

Hope that helps!
Dan


-
danprim
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1821257.htm
AddThis Social Bookmark Button