|
Hi
I'm trying to modify an Xml file. This is the content of the Xml. The problem is that after changes, it will creates a copy of the content of the Xml file without changing the old content.
Before changes :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
After changes :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataBase\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
The code is :
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
FileStream reader = new FileStream(this._XmlFilePath, FileMode.Open, FileAccess.ReadWrite);
xdoc.XmlResolver = null;
xdoc.Load(reader);
System.Xml.XmlElement Node = (System.Xml.XmlElement)xdoc.DocumentElement.SelectSingleNode("//configuration/connectionStrings/add[@name=\"Application.Properties.Settings.DBConnectionString\"]");
if (Node != null)
{
Node.Attributes.GetNamedItem("Source").Value = "C:\DataDabe\DB.mdb";
xdoc.Save(reader);
reader.Close();
}
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
yes it suppose to do, because you are saving the xml in same stream.
try this
if (Node != null)
{
Node.Attributes.GetNamedItem("Source").Value = "C:\DataDabe\DB.mdb";
reader.Position = 0;
xdoc.Save(reader);
reader.Close();
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
hi thanks for the answer..it partially solved the problem.
now the result is :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataBase\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>tem.Data.OleDb" />
</connectionStrings>
</configuration>
this part is wrong :
tem.Data.OleDb" />
</connectionStrings>
</configuration>
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
okay do this
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.XmlResolver = null;
xdoc.Load(this._XmlFilePath);
System.Xml.XmlElement Node = (System.Xml.XmlElement)xdoc.DocumentElement.SelectSingleNode("//configuration/connectionStrings/add[@name=\"Application.Properties.Settings.DBConnectionString\"]");
if (Node != null)
{
Node.Attributes.GetNamedItem("Source").Value = "C:\DataDabe\DB.mdb";
xdoc.Save(this._XmlFilePath);
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
perfect thanks!!!
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
Hi All,
I have one weird problem in my XSL transform. The Java code is writing data into XSL using XMLWriter.
The Java code line looks like this ...
xmlWriter.writeElement( "notation", "(A)=(B)+(C)");
I dont want to do any String concatenation here and I wanted the out put in XSL as (A)=(B)+(C)
But I see the + symbol is missing in my XSL out put and value get displayed as (A)=(B)(C)
I use UTF-8 encode in my XSL .
Is there any encoding mechanism ? Is it possible to handle at Java or XML level ?
Please share your thoughts out of your experience .
* Thanks
|
|
|
|
|
I am using Silverlight 4 and WCF
In the WCF I write a datatable to a stringreader and return the string to the UI. In the UI I need to turn the string into an object (Telerik datatable class) which requires that I read the elements to create the columns and the data to populate the rows.
Problem is when the data has null values the xml does not get a full set of elements, the table is invalid in the UI. To solve this I want to include the schema in the string passed to the UI.
However I cannot work out how to get the schema out of the xDocument. This receives the string and creates the xDocument, I then need to get the schema to create the columns
void GenericProcedureCompleted(object sender, GenericProcedureCompletedEventArgs e)
{
svcClient.GenericProcedureCompleted -= new EventHandler<GenericProcedureCompletedEventArgs>(GenericProcedureCompleted);
ShowError(e.sErrorMsg);
if (!string.IsNullOrEmpty(e.Result))
{
System.IO.StringReader sr = new System.IO.StringReader(e.Result);
XDocument xDoc = XDocument.Load(sr);
CreateTable(xDoc);
}
}
This is currently using the elements to create the table
xEl = xDoc.Descendants("XMLData").ToList()[0];
foreach (XElement xe in xEl.Elements())
{
oCol = new CTUI.Data.DataColumn();
oCol.ColumnName = xe.Name.LocalName;
oCol.DataType = typeof(string);
dtData.Columns.Add(oCol);
}
Ant suggestions that are valid for Silverlight 4 will be welcome. Note Silverlight 4 does not support all xml structures.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Everyone,
Can anyone help me in xsl drop down which i need to display the selected value. I have two pages.
First Page
I have written a html tag in xsl which has six options say one,two....
After selecting one of the value it is stored in the database.
Second Page
Here also I have written the same html tag in xsl. but here the issue is i need to display the selected value which is retrieved from database.
Please let me know if any one has a sample code
Thanks in Advance .
Regards,
Manowj
|
|
|
|
|
Hi, I asked a Q in C# forum, but i also trying here.
please help me with this Q
many thanks
|
|
|
|
|
Hi.
How can i save a word document to xml format for parsing later with xslt.
I noticed that word 2007-2010 document are constructed with the openxml format so i can use openxml tools to save it.
But word 2000-2003 seems to be in binary format.
Is there a tool that i can use for this mission?
Thanks
|
|
|
|
|
don't post same question in more than one forum.
It create cross post. be aware from it.
|
|
|
|
|
How do I include PHP codes in an XML file?
I have a FLASH Gallery that i want to alter the names of the photo's
but i can't do that because i don't know how to include the PHP in the XML file ,, can you help me ?
|
|
|
|
|
We need more details in order to answer this.
Why do you want to embed PHP in the XML? How is the XML being used? This sounds potentially dangerous.
|
|
|
|
|
how I can create multiple XML files from a single XML file using xsltproc?
|
|
|
|
|
If you are using XSL 2, you can use xsl:result-document to target multiple output documents.
|
|
|
|
|
I must use XSLTProc
it does not support XSLT 2.0
|
|
|
|
|
The only way I can see to do this with this tool then is to have multiple XSLT files and run them in sequence. It's not pretty, but XSLT 1 was not designed for a 1-in to many-out scenario.
|
|
|
|
|
|
You are welcome. I hope we have helped.
|
|
|
|
|
Good afternoon.
I have the following XML file structure:
<?xml version="1.0" ?>
- <WEB_SITE>
- <RECORD>
<Name>Homepage</Name>
<Address>http:
</RECORD>
</WEB_SITE>
I would like to derive the URL from the XML file if the name is Homepage.
I have this so far:
string strtmpName = string.Empty;
string strtmpAddress = string.Empty;
XmlTextReader reader = null;
XDocument xmlDoc = new XDocument();
reader = new XmlTextReader(cv.StrIndivPath1 + strLANID + cv.StrIndivPath2 + "Website.xml");
xmlDoc = XDocument.Load(reader);
reader.Close();
XElement Results = XElement.Parse(xmlDoc.ToString());
foreach (XElement xe in Results.Elements("RECORD").Descendants())
{
switch (xe.Name.ToString())
{
case "Name":
if (xe.Value.ToLower() == "homepage")
{
strtmpAddress = Results.Elements("RECORD").Descendants("Address").ToString();
MessageBox.Show(strtmpAddress);
}
break;
default:
break;
}
}
Any suggestions? Thank you, WHEELS
|
|
|
|
|
XPath can be used. Here is how it works:
String myXPath="/WEB_SITE/RECORD[Name='Homepage']/Address";
XmlNodeList myNodeList=xmlDoc.SelectNodes(myXPath);
XmlNode myXmlNode;
foreach (myXmlNode in xmlNodeList)
{
MessageBox.Show(myXmlNode.Value);
}
Cheers!
|
|
|
|
|
I am getting a Type and identifier are both required in a forach statement.
|
|
|
|
|
well you have to add this :
using System.Xml.Xpath;
so that it can identify the XPath.
|
|
|
|
|
Excellent. That does the trick. Thank you.
|
|
|
|
|