Pages

Friday, June 6, 2008

Extreme Frustration with XML

Ok, given the following XML...
<?xml version="1.0" encoding="utf-8" ?>
<queries>
    <query name="MatchUser1">
        <sql>
            SELECT     st_abbr AS state, lic_number AS licensenumber, lname AS lastname, fname AS firstname, zip
            FROM         GovtRegistry
            WHERE     (st_abbr = @STATE) AND (lic_number = @LICENSE) AND (fname = @FIRSTNAME) AND (lname = @LASTNAME) AND (zip LIKE @ZIP)
        </sql>
    </query>
    <query name="MatchUser2">
        <sql>
            SELECT     st_abbr AS state, lic_number AS licensenumber, lname AS lastname, fname AS firstname, zip
            FROM         GovtRegistry
            WHERE     (st_abbr = @STATE) AND (lic_number = @LICENSE)
        </sql>
    </query>
</queries>

How do I do this?

  XmlDocument document = new XmlDocument();
  document.Load("SomeFile.XML");
  XmlNode myQuery=document.find("MatchUser1");

  //this should give the text from the "sql" field of MatchUser1.
  string SQL = myQuery["sql"].value;  

What am I missing here? All I can find online is how to manually walk from node to node, testing the types of the nodes. The whole point of XML used to be that it was simple to organize, store, and retrieve data!

No comments:

Share This!

Contact Us

Name

Email *

Message *