L
Lee
Hello,
I am having some problem iterating over nodes. I keep getting the same
value using SelectSingleNode even though the nodes does not have that
value:
XML Document:
<?xml version="1.0" encoding="utf-8" ?>
<Class>
<ClassName>testItem</ClassName>
<DBTableName>Servers</DBTableName>
<IDField>
<ClassFieldName>ServerID</ClassFieldName>
<DBFieldName>ServerID</DBFieldName>
<DBFieldType>5</DBFieldType>
<AutoGenerated>False</AutoGenerated>
<GeneratorName>None</GeneratorName>
</IDField>
<Fields>
<Field>
<ClassFieldName>ServerFirst</ClassFieldName>
<DBFieldName>ServerFirst</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
<Field>
<ClassFieldName>ServerLast</ClassFieldName>
<DBFieldName>ServerLast</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
<Field>
<ClassFieldName>PositionName</ClassFieldName>
<DBFieldName>PositionName</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
</Fields>
</Class>
In my code I have:
XmlNode node = Doc.SelectSingleNode("//Class//Fields");
foreach (XmlNode nd in node)
{
DTField field = new DTField(nd);
_Fields.Add(field);
}
The constructor for the DTField object is as follows:
public DTField(XmlNode fieldNode)
{
_ClassFieldName = fieldNode.SelectSingleNode
("//Field//ClassFieldName").InnerText;
_DBFieldName =
fieldNode.SelectSingleNode("//Field//DBFieldName").InnerText;
int fType =
int.Parse(fieldNode.SelectSingleNode("//Field//DBFieldType").InnerText);
_DBFieldType = (DTDBFieldType)fType;
}
Now, I have put breakpoints all over the see what the values are when
they get called, etc. There are 3 Field nodes in the xml doc, but if I
put a break point in the DTField constructor the value assigned to
_ClassFieldName is *always* "ServerFirst", the value for the first node.
Wierd thing is that intellisense shows the real values as they should
be when I hover over the fieldNode object during debug.
--
Warm Regards,
Lee
"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
I am having some problem iterating over nodes. I keep getting the same
value using SelectSingleNode even though the nodes does not have that
value:
XML Document:
<?xml version="1.0" encoding="utf-8" ?>
<Class>
<ClassName>testItem</ClassName>
<DBTableName>Servers</DBTableName>
<IDField>
<ClassFieldName>ServerID</ClassFieldName>
<DBFieldName>ServerID</DBFieldName>
<DBFieldType>5</DBFieldType>
<AutoGenerated>False</AutoGenerated>
<GeneratorName>None</GeneratorName>
</IDField>
<Fields>
<Field>
<ClassFieldName>ServerFirst</ClassFieldName>
<DBFieldName>ServerFirst</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
<Field>
<ClassFieldName>ServerLast</ClassFieldName>
<DBFieldName>ServerLast</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
<Field>
<ClassFieldName>PositionName</ClassFieldName>
<DBFieldName>PositionName</DBFieldName>
<DBFieldType>9</DBFieldType>
</Field>
</Fields>
</Class>
In my code I have:
XmlNode node = Doc.SelectSingleNode("//Class//Fields");
foreach (XmlNode nd in node)
{
DTField field = new DTField(nd);
_Fields.Add(field);
}
The constructor for the DTField object is as follows:
public DTField(XmlNode fieldNode)
{
_ClassFieldName = fieldNode.SelectSingleNode
("//Field//ClassFieldName").InnerText;
_DBFieldName =
fieldNode.SelectSingleNode("//Field//DBFieldName").InnerText;
int fType =
int.Parse(fieldNode.SelectSingleNode("//Field//DBFieldType").InnerText);
_DBFieldType = (DTDBFieldType)fType;
}
Now, I have put breakpoints all over the see what the values are when
they get called, etc. There are 3 Field nodes in the xml doc, but if I
put a break point in the DTField constructor the value assigned to
_ClassFieldName is *always* "ServerFirst", the value for the first node.
Wierd thing is that intellisense shows the real values as they should
be when I hover over the fieldNode object during debug.
--
Warm Regards,
Lee
"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."