|
XML is a readable compound document file format (IStorage/IStream folders/files metaphore). At each level you may have an arbitrarily deep set of children, and so on. That's why it simplifies versioning a lot over time : no need to break a file format, just add new storages.
|
|
|
|
|
I have this code snipet in my c# classs that generates a string containg xml data.
//build xml data
StringWriter xmlStringWriter = null;
XmlTextWriter xmlWriter = null;
string xmlString = "";
StringBuilder xmlStringBuilder = new StringBuilder();
try
{
xmlStringWriter = new StringWriter(xmlStringBuilder);
xmlWriter = new XmlTextWriter((xmlStringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(); //start document
//populate xml
However, the generated xml string contains the header as:
Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
|
|
|
|
|
It appears that you did not check the display message as-is (no HTML).
Are you trying to save an XML document inside a single string to then include in a second instance of something else (be it a XML doc or what ever?)
"I will find a new sig someday."
|
|
|
|
|
I have a problem with converting all serialized data of MFC Object such as COleClientItem, CDocItem and CObject to XML. I would appreciate it if someone could suggest me how to solve this problem.
Thank very much for your help.
|
|
|
|
|
I think you need to be a little more explict on what you are asking. A CObject can contain anything so your question is really how do I serialize all possible data in all formats as XML.
"I will find a new sig someday."
|
|
|
|
|
Not sure if this is the right place to post, but...
I am trying to read and write attributes from a DOM.
The attributes are of type base64Binary, and I am using IXMLDOMElement::setAttribute(BSTR, VARIANT). How to I package/assign binary data (currently a CDWordArray, but I'm very flexible!!) into/from the variant?
Thanks!!!
|
|
|
|
|
Using BSTR, Variant should be fine but keep in mind that the memory block you are writting to the document must be compliant with allowed characters. This is espcially true with using the attribute data blocks vs a CData section. Just think of handling the transmission over a http connection. You would have to encode/decode the data. The same concept can apply here. Encode the binary into a string and set it to be the attribute value is one path I have used for smaller sets of information.
"I will find a new sig someday."
|
|
|
|
|
Thanks, no one seems to know much about this.....
I have no experiance with http connections/communictions. Is it possible for you to dumb it down a bit?
Encoding/decoding to me means stripping out the " ", "<", ">" etc characters, and replacing them when reading. Is this true? Are you aware of any functions available that will do this for me? I've found http://www.codeproject.com/internet/mimesniffer.asp Is this the sort of thing I should be using?
My data will typically go to 20 to 30 attributes, each of which will be less than 1 KByte.
|
|
|
|
|
Here is some code I did awhile back.
You need to remove nondisplay as well as conflicting characters from the display.
CString EnCodeStr(CString ToCode)
{
CString RetStr,AddStr;
int i,max;
unsigned short asc;
unsigned char c;
max = (unsigned int)ToCode.GetLength();
// For binary you need to send the length, The block could have zeros
for(i=0;i<max;i++)
{
c =="" tocode[i];
asc="c;
if(asc">47 && asc<58)
{
RetStr+=c;
}
else if(asc>64 && asc<91)
{
RetStr+=c;
}
else if(asc>96 && asc<123)
{
RetStr+=c;
}
else if(asc==32)
{
RetStr+="+";
}
else
{
AddStr.Format("%%%02x",asc);
RetStr+=AddStr;
}
}
return RetStr;
}
CString DeCodeStr(CString ToCode)
{
CString RetStr,AddStr;
int i,max;
unsigned short asc;
unsigned char c;
max = (unsigned int)ToCode.GetLength();
for(i=0;i<max;)
{
c =="" tocode[i];
asc="c;
if(asc==37)
{
AddStr=ToCode.Mid(i+1,2);
i+=3;
sscanf((LPCTSTR)AddStr,"%2x",&asc);
RetStr+=(char)asc;
}
else" if(asc="=43)
{
RetStr" +=" " ;
i++;
}
else
{
retstr="" retstr;
}
for="" smaller="" blocks="" that="" you="" mention="" this="" should="" be="" ok.
now="" i="" am="" assuming="" a="" mfc="" solution="" is="" ok.
to="" get="" the="" data="" into="" string="" one="" option="" to="" use="" cmemfile="" detach()="" and="" attach()="" functions.
sorry="" do="" not="" have="" time="" sample.="" would="" think="" could="" search="" on="" above.
=""
<b="">"I will find a new sig someday."
|
|
|
|
|
That sample's great, thanks. My main concern was what you meant by coding and encoding. If that's good enough then fantastic!!!!
thanks again.
|
|
|
|
|
Glad it helped. Take care.
"I will find a new sig someday."
|
|
|
|
|
Maybe I am missing what Michael is getting at but I don't think he is entirely correct. The base64Binary datatype by definition doesn't require any replacements to be legal in an xml document as when it is encoded it uses the characters 0-9 a-z A-Z '+' '/' ie no replacements required see section 6.8 of http://www.ietf.org/rfc/rfc2045.txt for details (this page is linked to by the Schema spec). Also be aware that most XML DOM do translations required ie you set strings containing '>' '&' etc and they will automatically be converted on output to < and &, however I'm not sure if this is the case for binary types.
If possible I would be tempted to use the hexBinary datatype as I find that easier to understand, two characters (0-9 a-f) are used to represent each hex octet ie 0x7f10 would be "7f10" in your XML doc.
Hope I haven't confused you...
|
|
|
|
|
No, that makes a bit more sense to me, and sounds easier to implement and check.
Is there an easy way to convert the 0x7f10 to "7f10"?
sprintf("%08h", intArray[0]) is OK for an int, but a bit tedious for arrays.
Is there a "short cut" here, or am I stuck with a loop?
Being able to calculate the length of the final string from the input string seems to me like a major advantage over Michael's code.
|
|
|
|
|
Thanks for correcting this. I guess I have been working to long. I totally over looked base64Binary was mentioned and just read a binary memory block in a BSTR field.
Take Care.
"I will find a new sig someday."
|
|
|
|
|
I use the MSXML IXMLDOMDocument to load and save settings of a Visual C++ Project. My code looks like this:
<br />
hr = Document.CoCreateInstance(__uuidof(DOMDocument));<br />
if (FAILED(hr) || (Document.p == NULL)) throw (IDS_XML_CANT_CREATE_XML_PARSER);<br />
<br />
VARIANT_BOOL Success = false;<br />
hr = Document->load(CComVariant(m_szFilename), &Success);<br />
if (FAILED(hr) || !Success) throw (IDS_XML_SETTINGS_CANT_LOAD_SETTINGS);<br />
Everything works fine and is square with the MSDN recommandations. But I still have a tiny problem: I decided to use XML in order to allow my users to manually edit the conf file but right now, the parser writes everything on a single row, making it hard to read.
It is important to tell the parser to write tabs, spaces and linefeeds ...
but how ???
|
|
|
|
|
Look for the whitespace settings (options). carraige returns and line feeds are just child text nodes.
Your users should be able to add the linefeed text manually and not impact your reading the data back in as a last option.
"I will find a new sig someday."
|
|
|
|
|
How come the "Copy Project" option in VS.NET is always disabled whenever I need to transfer a finished web service on my local computer to my remote web host's server? (I was always able to use this method to tranfer my ASP.NET projects).
Therefore, I had to copy the files manually via FTP. The files I copied were:
1) myService.asmx
2) myService.vsdisco
3) global.asax
4) web.config
5) bin folder which contains: myService.dll
All these files and the "bin" folder were copied to a folder called MyServiceFolder located at the root of my website's directory structure. But whenever I try to access the service (http://www.mysite.com/MyServiceFolder/myService.asmx) it fails. And it will not display the specific error because it could not locate the web.config (where <customerrors="off">).
However, when I move the web.config file out of the MyServiceFolder and into the parent folder, and tried it again, it was able to tell me the specific error: "Parser Error Message: Could not create type 'MyNamespace.MyClass'." But this means that my web service is still not working.
After some more trial and error, I was able to access my web service. What I did was that I also moved the "bin" folder out of the "MyServicefolder" and into the parent folder (where web.config is sitting). This made everything to work.
The location of my files on the server now looks like this (which is kinda too messy):
1) /web.config
2) /bin/myService.dll
3) /MyServiceFolder/myService.asmx
3) /MyServiceFolder/myService.vsdisco
4) /MyServiceFolder/global.asax
But the point is that I want to be able to organize all of my projects (web service, asp.net apps, etc) into their own folders on the server. So my big question is how can I put this web service into one folder such as MyServiceFolder, and make it work?
Is there some configuration/setup file where I can edit the path directories?
My other big question is how come I cannot use the "Copy Project" option to transfer web services to a remote server?
PLEASE HELP! Thanks.
|
|
|
|
|
Pls look at the link below so as to understand my problem..... its just a very short page so pls look at it.....
http://www.xmlfiles.com/articles/michael/htmlxml/default.asp
For the above link, the datas are being saved to xml using 'processForm.asp', if i cant use 'ASP' and my only choices are 'JSP' or 'Java' , 'XSL' to display. Can it be done???
Any websites that have similar examples or links will be greatly thankful.....
|
|
|
|
|
|
I am working on a parser using VC++ that utilizes MSXML 4.0. I have built a release version . I need to deploy this on another machine that doesnt have MSXML installed. How can I know which components(.ocx's or dll's) to include ?
Please help
|
|
|
|
|
|
You may want to check the legal redistribution on this. It may require you to use their setup vs just including the pieces.
"I will find a new sig someday."
|
|
|
|
|
Thanks for the reply. I would like to know how exactly to use the cab file .
|
|
|
|
|
You may want to ask Richard this. It has been several years since I actually prepared any distributions. At that time I was using the Wise Installer product line.
"I will find a new sig someday."
|
|
|
|
|
Does anybody know about a DTD repository where I can find already defined DTDs for specific applications. For example, I am currently looking for a DTD that defines the rules for XML files that are to include bug information. I would like to integrate this into an Open Source bugtracker.
http://mantisbt.sourceforge.net[^]
Regards,
Victor
phpWebNotes is a page annotation system modelled after php.net.
http://webnotes.sourceforge.net/demo.php[^]
|
|
|
|