Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
QuestionMissing System.Drawing.Point Pin
Andy H10-Jul-06 4:56
Andy H10-Jul-06 4:56 
AnswerRe: Missing System.Drawing.Point Pin
Andy H10-Jul-06 5:00
Andy H10-Jul-06 5:00 
QuestionUser objects limit in XP Pin
atuldeore10-Jul-06 4:26
atuldeore10-Jul-06 4:26 
AnswerRe: User objects limit in XP Pin
S. Senthil Kumar10-Jul-06 6:18
S. Senthil Kumar10-Jul-06 6:18 
QuestionSuppress Paint Event Pin
Andrei Ungureanu10-Jul-06 3:49
Andrei Ungureanu10-Jul-06 3:49 
AnswerRe: Suppress Paint Event Pin
LongRange.Shooter10-Jul-06 4:03
LongRange.Shooter10-Jul-06 4:03 
AnswerRe: Suppress Paint Event Pin
Josh Smith10-Jul-06 4:38
Josh Smith10-Jul-06 4:38 
Questiongetting XML Attribute doesn't work [modified] Pin
Schimaera10-Jul-06 3:34
Schimaera10-Jul-06 3:34 
Hi @all,

i have a big problem. I want to read an attribute from the following XML-File:
-------------
<main>

<equations>
<rule name = "equation1"
calc = "D=A+B+3*C"></rule>

<rule name = "equation2"
calc = "E=A*B+C*D"></rule>

<rule name = "equation3"
calc = "C=B/A"></rule>
</equations>



<values>
<rule name = "equation1">
<Source obj = "12.3"
field = "A"></Source>

<Source obj = "1"
field = "B"></Source>

<Source obj = "23"
field = "C"></Source>
</rule>


<rule name = "equation2">
<Source obj = "1"
field = "A"></Source>

<Source obj = "1"
field = "B"></Source>

<Source obj = "7"
field = "C"></Source>

<Source obj = "6"
field = "D"></Source>
</rule>


<rule name = "equation3">
<Source obj = "12.3"
field = "A"></Source>

<Source obj = "1"
field = "B"></Source>
</rule>
</values>
</main>
---------------

So tried to get the "equation1" from the first rule segment in value with the following code:

-----------------
XPathDocument document = new XPathDocument("test.xml");
XPathNavigator navigator = document.CreateNavigator();

XPathNodeIterator name = navigator.Select("main/values/rule[0]");

string i = name.Current.GetAttribute("name", string.empty);
-----------------

or:
-----------------
XPathNodeIterator name =navigator.Select("main/values/rule[0]/@name");

if (name.MoveNext())
{
string i = name.Current.Value;
}
-----------------


Nothing works! I'am getting an empty string (""). If I debug I see name->Current->HasAttribute = false.

I dont know what I can do. Can you help me please?

Thank you very much!

(sorry for my english, my native language is not english Wink | ;-)

-- modified at 9:39 Monday 10th July, 2006
AnswerRe: getting XML Attribute doesn't work Pin
Andrei Ungureanu10-Jul-06 3:46
Andrei Ungureanu10-Jul-06 3:46 
AnswerRe: getting XML Attribute doesn't work Pin
stancrm10-Jul-06 3:49
stancrm10-Jul-06 3:49 
GeneralRe: getting XML Attribute doesn't work Pin
Schimaera10-Jul-06 4:24
Schimaera10-Jul-06 4:24 
Questionadd control to listBox Pin
TAREQ F ABUZUHRI10-Jul-06 3:14
TAREQ F ABUZUHRI10-Jul-06 3:14 
AnswerRe: add control to listBox Pin
LongRange.Shooter10-Jul-06 4:08
LongRange.Shooter10-Jul-06 4:08 
GeneralRe: add control to listBox Pin
Josh Smith10-Jul-06 4:40
Josh Smith10-Jul-06 4:40 
AnswerRe: add control to listBox Pin
Andrew Lygin10-Jul-06 10:07
Andrew Lygin10-Jul-06 10:07 
Questionms access problem :( help please ... Pin
cmpeng3410-Jul-06 2:38
cmpeng3410-Jul-06 2:38 
AnswerRe: ms access problem :( help please ... Pin
LongRange.Shooter10-Jul-06 4:13
LongRange.Shooter10-Jul-06 4:13 
Questionchange WindowsForm Pin
realmontanakid10-Jul-06 2:25
realmontanakid10-Jul-06 2:25 
AnswerRe: change WindowsForm Pin
stancrm10-Jul-06 2:36
stancrm10-Jul-06 2:36 
GeneralRe: change WindowsForm Pin
Jun Du10-Jul-06 4:36
Jun Du10-Jul-06 4:36 
AnswerRe: change WindowsForm Pin
Andrei Ungureanu10-Jul-06 3:37
Andrei Ungureanu10-Jul-06 3:37 
QuestionListViewItemSorter and Icomparer [modified] Pin
livez10-Jul-06 1:26
livez10-Jul-06 1:26 
AnswerRe: ListViewItemSorter and Icomparer Pin
Robert Rohde10-Jul-06 3:24
Robert Rohde10-Jul-06 3:24 
GeneralRe: ListViewItemSorter and Icomparer [modified] Pin
livez10-Jul-06 3:41
livez10-Jul-06 3:41 
QuestionWord DOC To String Pin
eraserk10-Jul-06 1:19
eraserk10-Jul-06 1:19 

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.