S
sitemap
Hello.
I have a problem to accessing the right clindNodes from the xml.
I have many "step" elements with id.
I want to get the attributes from the 5 "matrix" elements, depending on
parent "step" id ( example - if some var(MyVariable) = 2, the code
should get the 5 matrix attributes that have a parent <step id="2" >).
My codea always returning the 5 matrix attributes only from step
id="1", and does not mather that i change the MyVariable to 2, 3 ..
Please help
This is my code:
mainForm.xmldoc = new XmlDocument();
mainForm.xmldoc.Load("file.xml");
XmlNode onode = mainForm.xmldoc.DocumentElement;
XmlNodeList xmlnode =
mainForm.xmldoc.GetElementsByTagName("step");
for (int i = 0; i < xmlnode.Count; i++)
{
XmlAttributeCollection xmlattrc =
xmlnode.Attributes;
if (xmlnode.Attributes[0].Value.ToString() ==
MyVariable)
{
matnode =
mainForm.xmldoc.GetElementsByTagName("matrix");
for (int a = 0; a < matnode.Count; a++ ) {
matatt = matnode[a].Attributes;
}
}
}
there is the part of the xml:
<?xml version="1.0"?>
<DocRoot>
<steps>
<step id="1">
<matrixs>
<matrix mrp="20" i="100,5" lf="10,2" r="0,3" />
<matrix mrp="40" i="300" lf="50" r="20" />
<matrix mrp="60" i="500" lf="30" r="15" />
<matrix mrp="80" i="900" lf="20" r="8" />
<matrix mrp="100" i="1300" lf="90" r="52" />
</matrixs>
<vals it="0" mrp="20" soe="0" shi="0" irr="0" pp="0" />
</step>
<step id="2">
<matrixs>
<matrix mrp="20" i="100,5" lf="10,2" r="0,3" />
<matrix mrp="40" i="300" lf="50" r="20" />
<matrix mrp="60" i="500" lf="30" r="15" />
<matrix mrp="80" i="900" lf="20" r="8" />
<matrix mrp="100" i="1300" lf="90" r="52" />
</matrixs>
<vals it="0" mrp="20" soe="0" shi="0" irr="0" pp="0" />
</step>
..
..
<DocRoot>
Thanks in advance
I have a problem to accessing the right clindNodes from the xml.
I have many "step" elements with id.
I want to get the attributes from the 5 "matrix" elements, depending on
parent "step" id ( example - if some var(MyVariable) = 2, the code
should get the 5 matrix attributes that have a parent <step id="2" >).
My codea always returning the 5 matrix attributes only from step
id="1", and does not mather that i change the MyVariable to 2, 3 ..
Please help
This is my code:
mainForm.xmldoc = new XmlDocument();
mainForm.xmldoc.Load("file.xml");
XmlNode onode = mainForm.xmldoc.DocumentElement;
XmlNodeList xmlnode =
mainForm.xmldoc.GetElementsByTagName("step");
for (int i = 0; i < xmlnode.Count; i++)
{
XmlAttributeCollection xmlattrc =
xmlnode.Attributes;
if (xmlnode.Attributes[0].Value.ToString() ==
MyVariable)
{
matnode =
mainForm.xmldoc.GetElementsByTagName("matrix");
for (int a = 0; a < matnode.Count; a++ ) {
matatt = matnode[a].Attributes;
}
}
}
there is the part of the xml:
<?xml version="1.0"?>
<DocRoot>
<steps>
<step id="1">
<matrixs>
<matrix mrp="20" i="100,5" lf="10,2" r="0,3" />
<matrix mrp="40" i="300" lf="50" r="20" />
<matrix mrp="60" i="500" lf="30" r="15" />
<matrix mrp="80" i="900" lf="20" r="8" />
<matrix mrp="100" i="1300" lf="90" r="52" />
</matrixs>
<vals it="0" mrp="20" soe="0" shi="0" irr="0" pp="0" />
</step>
<step id="2">
<matrixs>
<matrix mrp="20" i="100,5" lf="10,2" r="0,3" />
<matrix mrp="40" i="300" lf="50" r="20" />
<matrix mrp="60" i="500" lf="30" r="15" />
<matrix mrp="80" i="900" lf="20" r="8" />
<matrix mrp="100" i="1300" lf="90" r="52" />
</matrixs>
<vals it="0" mrp="20" soe="0" shi="0" irr="0" pp="0" />
</step>
..
..
<DocRoot>
Thanks in advance