Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
QuestionCreate excel 97-2003 by Open XML SDK 2.5 ? Pin
emma.sun.sts4-Dec-13 15:36
emma.sun.sts4-Dec-13 15:36 
AnswerRe: Create excel 97-2003 by Open XML SDK 2.5 ? Pin
Richard MacCutchan4-Dec-13 22:16
mveRichard MacCutchan4-Dec-13 22:16 
GeneralRe: Create excel 97-2003 by Open XML SDK 2.5 ? Pin
emma.sun.sts8-Dec-13 15:22
emma.sun.sts8-Dec-13 15:22 
GeneralRe: Create excel 97-2003 by Open XML SDK 2.5 ? Pin
Richard MacCutchan8-Dec-13 22:05
mveRichard MacCutchan8-Dec-13 22:05 
Questionhow to read value at specifix XML node Pin
bimbambumbum4-Dec-13 11:10
bimbambumbum4-Dec-13 11:10 
AnswerRe: how to read value at specifix XML node Pin
Jason Gleim4-Dec-13 13:05
professionalJason Gleim4-Dec-13 13:05 
AnswerRe: how to read value at specifix XML node Pin
PIEBALDconsult4-Dec-13 13:34
mvePIEBALDconsult4-Dec-13 13:34 
AnswerRe: how to read value at specifix XML node Pin
HobbyProggy5-Dec-13 4:01
professionalHobbyProggy5-Dec-13 4:01 
Hey bimbambumbum,
that's my way of doing it, with this code you'll get the attributes to your specific node. Code is written for .Net Framework 3.5

Additionaly i posted the XML file so you can backtrace the work and derive your code from it.

All you need to have set up is
the xmlDoc and a xPathNavigator xmlNavi = xmlDoc.createNavi...

C#
public DataTable LoadValueConfig(string ControlName, string ParentName, string FormName)
        {
            DataTable _dt = new DataTable();
            _dt.Columns.Add("Name");
            _dt.Columns.Add("Value");
            
            //Move to root node
            _xmlNavi.MoveToRoot();
            //move to windowConfig Node
            _xmlNavi.MoveTo(_xmlNavi.SelectSingleNode("WindowConfig"));
            //if node of form exists move to it
            if (FormName != "") { _xmlNavi.MoveTo(_xmlNavi.SelectSingleNode(FormName)); }
            //if node of parent exists move to it e.g. bsAdminTest
            _xmlNavi.MoveTo(_xmlNavi.SelectSingleNode(ParentName));
            // if control Name exists move to it e.g. switchButton1
            if (_xmlNavi.MoveTo(_xmlNavi.SelectSingleNode(ControlName)))
            {
                _xmlNavi.MoveTo(_xmlNavi.SelectSingleNode(ControlName));
                //Move to first attribute
                _xmlNavi.MoveToFirstAttribute();
                // move through all Attributes and save the values into the DataTable
                do
                {
                    if (_xmlNavi.Value != "")
                    {
                        _dt.Rows.Add(_xmlNavi.Name, _xmlNavi.Value);
                    }
                // while able to move to next Attribute
                } while(_xmlNavi.MoveToNextAttribute());
            }
            
            return _dt;
        }


XML File:

XML
<WindowConfig>
  <kopiefrmHauptfenster Position="460:21" Size="878:1170" WindowState="Normal">
    <checkBoxItem1 chBoxCheck="True" />
    <bsAdminTest Active="False">
      <switchButton1 switch="False" />
      <richTextBoxEx1 Text="" />
    </bsAdminTest>
    <Project Active="True">
      <navigationPane1 CheckedButton="Projekte" Expanded="True" />
      <expandablePanel1 Expanded="True" />
    </Project>
  </kopiefrmHauptfenster>
</WindowConfig>


Edit: added the comments for more Explanation

Ist probably not the best and most comfortable solution but int works for me, optimizations appreciated
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}


modified 5-Dec-13 10:13am.

GeneralRe: how to read value at specifix XML node Pin
bimbambumbum5-Dec-13 7:19
bimbambumbum5-Dec-13 7:19 
QuestionPlease answer it is my biggest problem. Pin
Tera Mind4-Dec-13 10:59
professionalTera Mind4-Dec-13 10:59 
AnswerRe: Please answer it is my biggest problem. Pin
Mycroft Holmes4-Dec-13 11:44
professionalMycroft Holmes4-Dec-13 11:44 
GeneralRe: Please answer it is my biggest problem. Pin
Tera Mind4-Dec-13 12:01
professionalTera Mind4-Dec-13 12:01 
GeneralRe: Please answer it is my biggest problem. Pin
Mycroft Holmes4-Dec-13 16:13
professionalMycroft Holmes4-Dec-13 16:13 
AnswerRe: Please answer it is my biggest problem. Pin
OriginalGriff4-Dec-13 11:57
mveOriginalGriff4-Dec-13 11:57 
GeneralRe: Please answer it is my biggest problem. Pin
Tera Mind4-Dec-13 12:16
professionalTera Mind4-Dec-13 12:16 
GeneralRe: Please answer it is my biggest problem. Pin
OriginalGriff4-Dec-13 21:47
mveOriginalGriff4-Dec-13 21:47 
AnswerRe: Please answer it is my biggest problem. Pin
Richard MacCutchan4-Dec-13 22:13
mveRichard MacCutchan4-Dec-13 22:13 
AnswerRe: Please answer it is my biggest problem. Pin
WuRunZhe9-Dec-13 2:42
WuRunZhe9-Dec-13 2:42 
Questionif/then/else variable frustration Pin
Steve Embry4-Dec-13 9:56
Steve Embry4-Dec-13 9:56 
AnswerRe: if/then/else variable frustration Pin
Pete O'Hanlon4-Dec-13 10:07
mvePete O'Hanlon4-Dec-13 10:07 
GeneralRe: if/then/else variable frustration Pin
Steve Embry4-Dec-13 15:09
Steve Embry4-Dec-13 15:09 
GeneralRe: if/then/else variable frustration Pin
DRAYKKO5-Dec-13 8:05
professionalDRAYKKO5-Dec-13 8:05 
AnswerRe: if/then/else variable frustration Pin
Mycroft Holmes4-Dec-13 11:53
professionalMycroft Holmes4-Dec-13 11:53 
Questionif/then/else variable frustration Pin
Steve Embry4-Dec-13 9:51
Steve Embry4-Dec-13 9:51 
AnswerRe: if/then/else variable frustration Pin
s_magus4-Dec-13 10:08
s_magus4-Dec-13 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.