XML Code
<? XML version = "1.0" encoding = "UTF-8"?>
<Root>
<Env>
<Param name = "rate" value = "3"/>
<Param name = "url" value = "3"/>
</ENV>
<VR startpano = "start" width = "10" Height = "540" x = "0" Y = "0">
<Pano name = "url" url = "car/model/interiorpanorama/bjxd_i30/S-max.jpg">
</Pano>
</VR>
<Background file = "control/bg.jpg">
</Background>
</Root> backend CS code Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. xml;
Public partial class somepages_operatexml: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
String STR = readxml ();
Lblreadxml. Text = STR;
Savexml ();
}
Private string readxml ()
{
String strreturn = string. empty;
Xmldocument Doc = new xmldocument ();
Doc. Load (server. mappath ("~ /Images/config. xml "));
Xmlelement root = Doc. documentelement;
// Define the matching item name = "url"
String Path = @ "// * [@ name = 'url']";
// Search for matching items on the current node
Foreach (xmlnode node in root. selectnodes (PATH ))
{
Strreturn + = "Match:" + path;
Strreturn + = "node:" + node. Name;
Strreturn + = "<br/> ";
}
// Directly search for the read value of the specified Node
Xmlelement x = (xmlelement) root. selectsinglenode ("Vr ");
If (X! = NULL)
{
Strreturn + = x. getattribute ("startpano ");
}
Return strreturn;
}
Private void savexml ()
{
Xmldocument Doc = new xmldocument ();
Doc. Load (server. mappath ("~ /Images/config. xml "));
Xmlelement root = Doc. documentelement;
Xmlelement x = (xmlelement) root. selectsinglenode ("Vr ");
If (X! = NULL)
{
// Set node attributes
X. setattribute ("width1", "10 ");
// Create a node
Xmlelement X1 = Doc. createelement ("test ");
X1.setattribute ("width", "100 ");
// Add a node
X. appendchild (X1 );
// Save the XML
Doc. Save (server. mappath ("~ /Images/config. xml "));
}
}
}