|
There are two ways to use xml in Internet Explorer
- loading a document with .xml as file extension. The MSXML parser version used to parse the xml file, transform it using a xslt stylesheet, is hardcoded. You must upgrade Internet Explorer to use a different MSXML parser.
- writing JScript/VBScript code to create a COM instance of the MSXML parser within a web page. Since it's up to you to pass the progid of this object, you can choose whichever MSXML parser that might be installed. For instance, "Msxml2.DOMDocument.4.0" instead of "Microsoft.XmlDOM".
A sample JScript[^] code.
|
|
|
|
|
I was building the following code and I get this error,
"The call is ambiguous between the following methods or properties: 'string.String(char[])' and 'string.String(sbyte*)'"
FileStream strmSettings;
XmlDocument xmlDoc = new XmlDocument();
XmlNode nSetting;
string filePath =new String(null);
strmSettings = File.Open("options.xml", FileMode.Open);
xmlDoc.Load(strmSettings);
nSetting = xmlDoc.SelectSingleNode("/options");
if(nSetting != null)
filePath = nSetting.InnerText;
strmSettings.Close();
string fileName = DateTime.Now.ToString("yyyyMMdd_hhmm") + ".xml";
XmlTextWriter writer = new XmlTextWriter(filePath + fileName, null);
What does this non sense mean?
/\ |_ E X E GG
|
|
|
|
|
This is the line that does it:
string filePath =new String(null);
There are many different versions (overloads) of the String constructor, each of which take different arguments. The compiler can't figure out which one to use.
Either do:
string filePath = "";
OR
string filePath =new String();
OR
string filePath;
The way you have it, compiler can't figure out whether it's (char)null or (sbyte)null.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I've got it under control now... thanks...
/\ |_ E X E GG
|
|
|
|
|
string filePath = null;
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Ok, so I've got this little C# app that updates my asp.net weblog. I plan on passing it on to other people I know, but then I came across a problem...
The files are outputted to the "entries" folder (name by the year, month, day, hour, minute, but thats irrelivant...) located on my hard drive in... (the location is in bold below). So, my problem was that, what if they wanted to change the location of the entries folder... you know... export the files somewhere else on the hard drive.
string fileName = DateTime.Now.ToString("yyyyMMdd_hhmm") + ".xml";<br />
XmlTextWriter writer = new XmlTextWriter("<big>C:/inetpub/wwwroot/weblog/entries</big>/"+ fileName, null);
SO, then I put togeather a little options form (options.cs) with a text box to enter the location on the drive, and then you click 'OK' and then it is saved to "options.xml". (see the code below...)
private void buttonOK_Click(object sender, System.EventArgs e)<br />
{<br />
XmlTextWriter writer=new XmlTextWriter("options.xml", null);<br />
writer.Formatting=Formatting.Indented;<br />
writer.WriteStartDocument();<br />
writer.WriteStartElement("Options");<br />
{<br />
string entryFile=textBoxEntryFile.Text;<br />
writer.WriteStartElement("entryFile");<br />
writer.WriteString(entryFile);<br />
writer.WriteEndElement();<br />
}<br />
writer.WriteEndElement();<br />
writer.WriteEndDocument();<br />
writer.Close();<br />
Form.ActiveForm.Close();<br />
<br />
}
This is what the options.xml file looks like....
?xml version="1.0"?><br />
<Options><br />
<entryFile>C:\inetpub\wwwroot\weblog\entrys\</entryFile><br />
</Options>
Now, I need this...
XmlTextWriter writer = new XmlTextWriter("<big>C:/inetpub/wwwroot/weblog/entries</big>/"+ fileName, null);
...instead of saveing it evertime.... unconfigurable.... to "C:/inetpub/wwwroot/weblog/entries", but rather save the entries to what ever file it says in the "options.xml" file.
WHEW!... i hope that made sense... im not familar with the XmlTextReader (assuming that what is to be used...) stuff... thanks for all the help possible.
/\ |_ E X E GG
|
|
|
|
|
So what do you not know about this? How to write it to XML?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
uh... i want change the following code...
XmlTextWriter writer = new XmlTextWriter("C:/inetpub/wwwroot/weblog/entries/"+ fileName, null);
you see.... the bolded path... that's static... you can't change it, unless you edit the code in vs.net...
Now, I want it to get the path from an xml file, I already made(options.xml)... it looks like this...
<xml version blah blah blah...><br />
<path>path goes here</path>
do you think you can help?
/\ |_ E X E GG
|
|
|
|
|
private System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.Load("url");
<br/>
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path");
<br>
XmlTextWriter writer = new XmlTextWriter(xmlnode.InnerText + fileName, null);
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Is this right?
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();<br />
xml.Load("C:/Documents and Settings/Alex Egg/Desktop/Visual Studio Projects/RecordTimesheets/bin/Debug/options.xml"); <br />
<br />
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path"); <br />
<br />
string fileName = DateTime.Now.ToString("yyyyMMdd_hhmm") + ".xml";<br />
XmlTextWriter writer = new XmlTextWriter(xmlnode.InnerText + fileName, null);
isim not sure what this is about ("descendant::root/path");
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote:
xml.Load("C:/Documents and Settings/Alex Egg/Desktop/Visual Studio Projects/RecordTimesheets/bin/Debug/options.xml");
But then you are hard-coding this path. Maybe you can keep the XML file in the assembly path.
eggie5 wrote:
I don't get this part....
//get the xml path
//where root is the root element
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path");
here you are getting a node named "path" which is a child of the node named "root". The "descendant::" means you're starting from the top, and the path after "descendant::" specifies the path of the node you want to get.
***************[XML file section]*********************
<root>
<path>c:\somefolder\…</path>
</root>
***************[/XML file section]*********************
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
For this....
xml.Load("C:/Documents and Settings/Alex Egg/Desktop/Visual Studio Projects/RecordTimesheets/bin/Debug/options.xml");
...is what your saying, is that I should go like this...
xml.Load("C:/Documents and Settings/Alex Egg/Desktop/Visual Studio Projects/RecordTimesheets/bin/Debug/");
Also, im confused about this still...
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path");
... im confused as if im sopposed to fill something in here? Or do I just leave it as it is...
my xml file looks like this....
<?xml version="1.0"?><br />
<Options><br />
<entryFile>C:\inetpub\wwwroot\weblog\entrys\</entryFile><br />
</Options>
uh... please feel free to fill in the info for me;P
/\ |_ E X E GG
|
|
|
|
|
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::Options/entryFile");
eggie5 wrote:
...is what your saying, is that I should go like this...
I mean this:
xml.Load(Assembly.Location + @"\options.xml");
I'm off to bed - it's 'way late.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
you don't need
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path");
use:
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("/options");
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I don't get this part....
System.Xml.XmlNode xmlnode = xml.SelectSingleNode("descendant::root/path");
I don't know what to do with this...
Would you elaborate on it more? Thanks.
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote:
you can't change it, unless you edit the code in vs.net...
Now, I want it to get the path from an xml file, I already made(options.xml)... it looks like this...
<xml version="" blah="" blah...="">
<path>path goes here
do you think you can help?
Use App.config or web.config. That is what they are there for. If you users can edit an options.xml file then they are capable of editing a web.config file.
Put an appkey into your .config file and then in your code use the AppSettings class to retrieve the value. You do not need to use the XmlTextReader or anything else as the AppSettings class encapsulates that for you already. Very handy.
Don't re-invent the wheel with your own options.xml file, use what .NET provides
Paul Watson Bluegrass Cape Town, South Africa
brianwelsch wrote:
I find my day goes by more smoothly if I never question other peoples fantasies. My own disturb me enough.
|
|
|
|
|
Are you the guy who lost you windows XP CD? I saw your post somewhere, where someone told you where to download the ISO from MSDN... where is it?
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote:
Are you the guy who lost you windows XP CD? I saw your post somewhere, where someone told you where to download the ISO from MSDN... where is it?
I sure am that guy
You know that horrible tree-nav on the left? You have to wait until it is fully loaded, you can tell it is fully loaded when it closes up and not everything is expanded. I generally leave the MSDN Subscribers Download page open in the background for about 10 minutes before I try and find what I want in that tree-nav. It is there, under Platforms.
Paul Watson Bluegrass Cape Town, South Africa
brianwelsch wrote:
I find my day goes by more smoothly if I never question other peoples fantasies. My own disturb me enough.
|
|
|
|
|
Hi..
I'm interested in using an xml-based help system to develop a help system at my web site. I want to run this over the web, i.e., someone connects to a URL, and their browser renders a given help page. The system has to be only moderately fancy. I just want basic things like "BACK", "UP", an index, a table of contents, good-looking output, cross-links, and the ability to put arbitrary HML inside the actual page. I would be happy to edit the source for the help using the vi editor.
I could write my own, but I'd rather find something that suits my needs that already exists. I see that Webworks has a product called WordHelp, but WordHelp appears to be available only as part of WebWorks Publisher Professional, which costs $1295 , which is more than I want to spend. There is also something at http://www.isparp.ukgateway.net/angband/helppatch/ but that doesn't look like it has quite enough functionality.
Does anyone have any other ideas?
Andrew
|
|
|
|
|
|
I’m new to XML.
I read on http://www.w3schools.com/[^] that it’s important to understand that XML was designed to store, carry, and exchange data. XML was not designed to display data.
Why should I use XML in my website, when I’ve got a database driven website, and all my data is located in that database?
|
|
|
|
|
I'd pretty much say that if it ain't broke, don't fix it
When I was first introduced to XML, I went through the exact same thought process ("Why would I use this in my site?") and ended up dismissing it. However, it was good to at least know it existed; on a project a few months later, it suddenly dawned on me that XML would work really well for the task, and thus I set about learning as much as I could about XML-related technologies to get a grasp of what tools were available.
I think trying to graft XML into an existing (working) system is much like grabbing a hammer and pounding away at something until it looks like a nail. If you really want to get your feet wet in using XML, you can start by updating your site to be XHTML 1.0 valid. Then, play around with writing an XSLT translation to tweek things like removing links and extraneous style bits to produce a "printable" version of all your pages. Alternatively, you can learn the DOM or SAX API and write some code to do it. Either way, that should give you some ideas of how you can actually apply XML-related technologies.
Oh yeah, and have fun! Use XML to make your life easier, not harder.
- Mike
|
|
|
|
|
|
I am having a hard time converting a string representation of a xml-document into a dataset.
The case is:
1. I send a request to a server which answers with a xml-document in the form of a string.
2. Next I want to convert this string into a System.Data.DataSet and display it in a datagrid or some other.
It is giving me a really hard time figuring out how to do this.
I have tríed the following:
{
System.Xml.XmlDataDocument xmlDD = new System.Xml.XmlDataDocument();
System.Data.DataSet dsXML = new System.Data.DataSet();
xmlDD.LoadXml(strXml);
dsXml = xmlDD.DataSet;
}
This will generate following error "The IListSource does not contain any data sources."
I have tried the following, it works, but is a VERY bad idea for a webpage:
{
xmlDD.LoadXml(strXml);
xmlDD.Save(Server.MapPath("log") + "\\out.xml");
dsXml.ReadXml("\\out.xml");
}
Why can't I go directly from a string through a xmldocument to a dataset?
Any comments appreciated.
Preben Rasmussen
IT-consultant
|
|
|
|
|
One of the overloads of the ReadXml method accepts a TextReader object. The StringReader class is derived from TextReader , so you can just do:
System.IO.StringReader sr = new System.IO.StringReader(strXml);
System.Data.DataSet dsXML = new System.Data.DataSet();
dsXML.ReadXml(sr);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|