Today I met XML Attribute Value reading problem, first fromCodeNo errors are found in the train of thought and syntax query problems, Then I found the problem from the client and the server's response information. XML The property value does not appear in this XML String ( XML The string is determined based on the client commands that contain those attributes, that is, different client action commands will send different XML String), so an error occurs.
String clientcommand = " <Move user = \ " ZSP \ " Target = \ " Target_cell \ " Map = \ " Mapid \ " /> " ;
Xmldocument xmldoc = New Xmldocument (); // Instantiate an xmldocument object
Xmldoc. loadxml (clientcommand ); // Load as XML document
Xmlnode Node = Xmldoc. firstchild; // Extracting the first node of the XML document is actually a node here.
Xmlattribute user = Node. attributes [ " User " ];
String name = User. value. tostring (); // Assign the user attribute value to a string
Xmlattribute Map = Node. attributes [ " Map " ];
String clientmap = Map. value. tostring (); // Assign the value of the map attribute to a string
Console. writeline ( " Name: {0}, MAP: {1} " , Name, clientmap );