<?xml version="1.0" encoding="utf-16"?>
<componentDocuments>
<componentDocument Version="1.0">
<header>
<flow ID="GOGOGO" nodeID="Begin" >
<fileName>xml/workflows/SignOnFlow.xml</fileName>
<declares />
<sequence outcome="" />
</flow>
<returnStack />
<index>1</index>
</header>
<body>
<userInfo persist="true">
<InstitutionNo>0</InstitutionNo>
<BranchNo>0</BranchNo>
</userInfo>
<screenData persist="true">
<TranNo>100000</TranNo>
<DynamicKey>adsfarfadfgdgzaf43sdtgrwafasf</DynamicKey>
</screenData>
</body>
</componentDocument>
</componentDocuments>如何取得“fileName”元素下对应的值(即“xml/workflows/SignOnFlow.xml”)?
请大家帮忙解答一下,谢谢!
<componentDocuments>
<componentDocument Version="1.0">
<header>
<flow ID="GOGOGO" nodeID="Begin" >
<fileName>xml/workflows/SignOnFlow.xml</fileName>
<declares />
<sequence outcome="" />
</flow>
<returnStack />
<index>1</index>
</header>
<body>
<userInfo persist="true">
<InstitutionNo>0</InstitutionNo>
<BranchNo>0</BranchNo>
</userInfo>
<screenData persist="true">
<TranNo>100000</TranNo>
<DynamicKey>adsfarfadfgdgzaf43sdtgrwafasf</DynamicKey>
</screenData>
</body>
</componentDocument>
</componentDocuments>如何取得“fileName”元素下对应的值(即“xml/workflows/SignOnFlow.xml”)?
请大家帮忙解答一下,谢谢!
<componentDocuments>
<componentDocument Version=""1.0"">
<header>
<flow ID=""GOGOGO"" nodeID=""Begin"" >
<fileName>xml/workflows/SignOnFlow.xml </fileName>
<declares />
<sequence outcome="""" />
</flow>
<returnStack />
<index>1 </index>
</header>
<body>
<userInfo persist=""true"">
<InstitutionNo>0 </InstitutionNo>
<BranchNo>0 </BranchNo>
</userInfo>
<screenData persist=""true"">
<TranNo>100000 </TranNo>
<DynamicKey>adsfarfadfgdgzaf43sdtgrwafasf </DynamicKey>
</screenData>
</body>
</componentDocument>
</componentDocuments> "; XmlDocument xml = new XmlDocument();
xml.LoadXml(strContent); XmlNode node = xml.SelectSingleNode(@"//fileName"); string strValue = "";
if (node != null) { strValue = node.InnerText; }
XmlDocument xmldoc = new XmlDocument();
xml = XElement.Load(xmlpath);
XElement ele= xml.XPathSelectElement("componentDocuments/componentDocument/header/flow/fileName");
xml.LoadXml(strContent); XmlNode node = xml.SelectSingleNode(@"//fileName"); string strValue = "";
if (node != null) { strValue = node.InnerText; }
<?xml version="1.0" encoding="utf-16"?>
<componentDocuments>
<componentDocument Version="1.0">
<header>
<flow ID="GOGOGO" nodeID="Begin" >
<fileName>xml/workflows/SignOnFlow.xml </fileName>
<declares />
<sequence outcome="" />
</flow>
<returnStack />
<index>1 </index>
</header>
<body>
<userInfo persist="true">
<InstitutionNo>0 </InstitutionNo>
<BranchNo>0 </BranchNo>
</userInfo>
<screenData persist="true">
<TranNo>100000 </TranNo>
<DynamicKey>adsfarfadfgdgzaf43sdtgrwafasf </DynamicKey>
</screenData>
</body>
</componentDocument>
</componentDocuments>
即<fileName>xml/workflows/SignOnFlow.xml </fileName>
变为<fileName>c:\data\xml\workflows\SignOnFlow.xml </fileName>
谢谢!
XmlDocument doc = new XmlDocument();
doc.Load(xmlpath);
XmlElement root = doc.DocumentElement;
XmlNode comnode = root.SelectSingleNode("");
foreach (XmlNode n in comnode.ChildNodes)
{
if (n.Attributes.GetNamedItem("").Value == "")
{
Console.WriteLine(n.InnerXml.ToString());
}
}
doc.Save(xmlpath);
http://topic.csdn.net/u/20090515/12/619c10d1-af12-4c90-bfcd-101da5dd8ddf.html
现在的情况是,报文是程序运行时生成出来的,但是出了点问题,我现在需要写一个方法修改这个报文中<fileName>配置节的信息,将其由“<fileName>xml/workflows/SignOnFlow.xml </fileName>”改为“<fileName>c:\data\xml\workflows\SignOnFlow.xml </fileName>”后返回一个新的报文,现在可以取到这个节点并修改了,但是修改后该怎样保存到先前的报文中取呢?
请个人帮忙再解释解释吧,谢谢啦!