Click here to Skip to main content
15,908,254 members
Home / Discussions / C#
   

C#

 
QuestionSimulation mobile users in network Pin
trungtin13-Oct-09 0:10
trungtin13-Oct-09 0:10 
QuestionxmlDocument Pin
arkiboys12-Oct-09 23:40
arkiboys12-Oct-09 23:40 
AnswerRe: xmlDocument Pin
SeMartens12-Oct-09 23:55
SeMartens12-Oct-09 23:55 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 0:43
arkiboys13-Oct-09 0:43 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 0:46
SeMartens13-Oct-09 0:46 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 0:51
arkiboys13-Oct-09 0:51 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 1:02
SeMartens13-Oct-09 1:02 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 1:19
arkiboys13-Oct-09 1:19 
Hi,
I tried it with a bit of adjustments.
But I get this:

<column>
<ElementName>1234</ElementName>
<ElementValue>uyt</ElementValue>
<column>
<ElementName>newKey</ElementName>
<ElementValue>newValue</ElementValue>
</column>
</column>

instread of:

<column>
<ElementName>1234</ElementName>
<ElementValue>uyt</ElementValue>
<column>
<column>
<ElementName>newKey</ElementName>
<ElementValue>newValue</ElementValue>
</column>

-----------
This is the code:

Thanks

private void LoadXMLmodify()
{
XmlDocument doc = new XmlDocument();
doc.Load(strPath);

// Retrieve all prices.
XmlNodeList nodeList = doc.GetElementsByTagName("mapKey");

foreach (XmlNode node in nodeList)
{
string strValue = node.ChildNodes[0].Value.ToString();
if (strValue.ToLower() == "0024007")
{
if (node.NextSibling.InnerXml.Trim() == "1")
{
string strMapValue = node.NextSibling.InnerXml.Trim();

//Remove element...
//Debug.WriteLine("mapKey : " + strValue + " and mapValue : " + strMapValue + " removed.");
//node.RemoveChild(node.FirstChild);

//Add element...
XmlNode columnNode = doc.CreateElement("Mapping");
XmlNode elementKeyNode = doc.CreateElement("mapKey");
XmlNode elementValueNode = doc.CreateElement("mapValue");

elementKeyNode.InnerText = strValue;
elementValueNode.InnerText = "999";

columnNode.AppendChild(elementKeyNode);
columnNode.AppendChild(elementValueNode);

node.ParentNode.AppendChild(columnNode);

//string strMapValue = node.NextSibling.InnerText;
//Debug.WriteLine("mapValue changed from : " + strMapValue + " to : " + "newValue");
//node.NextSibling.InnerText = "newVlaue";

//doc.Save(strPath);
}
}
}

doc.Save(strPath);

}
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 1:25
SeMartens13-Oct-09 1:25 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 1:29
arkiboys13-Oct-09 1:29 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 1:32
SeMartens13-Oct-09 1:32 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 1:35
arkiboys13-Oct-09 1:35 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 1:38
SeMartens13-Oct-09 1:38 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 1:41
arkiboys13-Oct-09 1:41 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 1:47
SeMartens13-Oct-09 1:47 
GeneralRe: xmlDocument [modified] Pin
arkiboys13-Oct-09 1:59
arkiboys13-Oct-09 1:59 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 2:09
SeMartens13-Oct-09 2:09 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 2:16
arkiboys13-Oct-09 2:16 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 4:23
arkiboys13-Oct-09 4:23 
GeneralRe: xmlDocument Pin
SeMartens13-Oct-09 4:27
SeMartens13-Oct-09 4:27 
GeneralRe: xmlDocument Pin
arkiboys13-Oct-09 5:00
arkiboys13-Oct-09 5:00 
AnswerRe: xmlDocument Pin
Mirko198012-Oct-09 23:56
Mirko198012-Oct-09 23:56 
Questionprinting 2 document to same file/ preview Pin
samy10012-Oct-09 23:39
samy10012-Oct-09 23:39 
AnswerRe: printing 2 document to same file/ preview Pin
Henry Minute13-Oct-09 1:35
Henry Minute13-Oct-09 1:35 
GeneralRe: printing 2 document to same file/ preview Pin
samy10013-Oct-09 2:12
samy10013-Oct-09 2:12 

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.