What is the best way to parse a Fix Protocol message in C#Parsing XML with prefix, xpath and XmlName

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, good morning.<br/>
<br/>
Im trying to find a best way(with the best performance) to parse a Fix Protocol message.<br/>
Then I made some functions that return a value if I give a Fix Message and a Fix field. They work pretty well but I dont know if is the best way to do this.<br/>
See below:<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;

<span style="color:Blue; namespace FixField
{
<span style="color:Blue; class Program
{
<span style="color:Blue; private <span style="color:Blue; const <span style="color:Blue; char cEql = (<span style="color:Blue; char)61;
<span style="color:Blue; private <span style="color:Blue; const <span style="color:Blue; char cFixSep = (<span style="color:Blue; char)1;
<span style="color:Blue; private <span style="color:Blue; const<


Hi,<br/>
<br/>
I am having problem in reading my XML with xPath and XmlNamespaceManager. Please help.<br/>
<br/>
Here is my VB Code: <br/>
Dim xmlDoc, xmlAds As New XmlDocument()<br/>
xmlDoc.Load(strXMLFile)<br/>
Dim nsManager As New XmlNamespaceManager(xmlDoc.NameTable)<br/>
nsManager.AddNamespace("onl", "http://www.saxotech.com/online stories.xsd")<br/>
Dim StoryItems As XmlNodeList = xmlDoc.SelectNodes("onl:stories/onl:story/onl:content", nsManager)<br/>
Response.Write(StoryItems.Item(0).SelectSingleNode("heading").InnerText)<br/>
<br/>
My XML File: <br/>
<?xml version="1.0" encoding="UTF-8"?><br/>
<onl:stories xmlns:onl="http://www.saxotech.com/online" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.saxotech.com/online stories.xsd" site="jp" siteuri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp" count="10"
totalcount="144" pagenumber="1" pagesize="10" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories <br/>
<onl:story date="20121107" id="121109843" key="{13D80928-73F8-4209-B36C-F682D6F64B84}" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}" viewuri="http://JPedit.sx.atl.publicus.com/article/20121107/BOY/121109843 <br/>
<onl:metadata status="unpublished" priority="0 <br/>
<onl:modified by="colleenj" user="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/users/{97A9E7BD-6311-41EC-9FBA-B7D347E44A9C}" timestamp="2012-11-07T21:50:46Z" internaltimestamp="2012-11-07T22:17:49Z" /><br/>
<onl:created by="colleenj" user="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/users/{97A9E7BD-6311-41EC-9FBA-B7D347E44A9C}" timestamp="2012-11-07T21:50:46Z" /><br/>
<onl:published timestamp="2012-11-07T21:50:46Z" /><br/>
<onl:category id="BOY" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/categories/BOY <![CDATA[Event - Business of the Year]]></onl:category><br/>
</onl:metadata><br/>
<onl:content><br/>
<onl:heading><![CDATA[A Trbiute to Conrad M. Siegel]]></onl:heading><br/>
<onl:summary><![CDATA[A brief tribute video created by FGV and the Central Penn Business Journal to recognize Conrad M. Siegel, founder, chairman and CEO of Conrad Siegel Actuaries upon his induction into the Central
Penn Business Hall of Fame on November 1, 2012.<br/>
<br/>
http://www.cpbjnow.com/assets/mov/JP127109117.WMV Click here to watch the video. ]]></onl:summary><br/>
<onl:image viewuri="/storyimage/jp/20121107/BOY/121109843/AR/0/0/AR-121109843.jpg" softcropimagesuri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/content/image/softcropimages <br/>
<onl:heading><![CDATA[Conrad M. Siegel]]></onl:heading><br/>
<onl:byline><![CDATA[Amy Spangler]]></onl:byline><br/>
</onl:image><br/>
</onl:content><br/>
<onl:parents count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/parents" /><br/>
<onl:children count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/children" /><br/>
<onl:taxonomywords count="1" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/taxonomywords" /><br/>
<onl:geopoints count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/geopoints" /><br/>
<onl:extraimages count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/content/extraimages" /><br/>
<onl:mediafiles count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/content/mediafiles" /><br/>
<onl:staffmembers count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/staffmembers" /><br/>
<onl:comments count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{13D80928-73F8-4209-B36C-F682D6F64B84}/comments" /><br/>
</onl:story><br/>
<onl:story date="20121107" id="121109844" key="{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}" viewuri="http://JPedit.sx.atl.publicus.com/article/20121107/SPORTS/121109844 <br/>
<onl:metadata status="published" priority="0 <br/>
<onl:modified by="amyg" user="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/users/{D448C507-2C34-4BC1-9D8D-34360D50DB55}" timestamp="2012-11-07T20:25:35Z" internaltimestamp="2012-11-07T20:27:10Z" /><br/>
<onl:created by="amyg" user="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/users/{D448C507-2C34-4BC1-9D8D-34360D50DB55}" timestamp="2012-11-07T20:25:35Z" /><br/>
<onl:published timestamp="2012-11-07T20:00:00Z" /><br/>
<onl:category id="SPORTS" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/categories/SPORTS <![CDATA[Blog - Sports]]></onl:category><br/>
</onl:metadata><br/>
<onl:content><br/>
<onl:heading><![CDATA[Concessions: Quite the moneymaker for stadiums]]></onl:heading><br/>
<onl:summary><![CDATA[There&#8217;s a reason &#8220;Take Me Out To The Ballgame&#8221; includes a verse about peanuts and Cracker Jack. Even as far back as 1908, when the song was written, concessions were
an important part of the fan experience &#8211; and the team&#8217;s bottom line. ]]></onl:summary><br/>
<onl:byline><![CDATA[Bill Sayer]]></onl:byline><br/>
</onl:content><br/>
<onl:parents count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/parents" /><br/>
<onl:children count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/children" /><br/>
<onl:taxonomywords count="1" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/taxonomywords" /><br/>
<onl:geopoints count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/geopoints" /><br/>
<onl:extraimages count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/content/extraimages" /><br/>
<onl:mediafiles count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/content/mediafiles" /><br/>
<onl:staffmembers count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/staffmembers" /><br/>
<onl:comments count="0" uri="http://JPedit.sx.atl.publicus.com/apps/ows.dll/sites/jp/stories/{AB1DACF8-C54D-42F4-BCB3-C820260D3CB9}/comments" /><br/>
</onl:story><br/>
</onl:stories>

View the full article
 
Back
Top