|
Sorry but this was my first post.
so here for clarifacation
...
//creating the the DOM document (mXmlDom)
//and select the root (mRoot4Write)
...
_bstr_t theValue("X"); //!!! the ASCII value
IXMLDOMNodePtr plastNode = mXmlDom->createNode(nodetyp,_bstr_t("T"),_bstr_t(""));
plastNode = mRoot4Write->appendChild(plastNode);
IXMLDOMNodePtr pNode = mXmlDom->createTextNode(theValue);
pNode = plastNode->appendChild(pNode);
pNode.Release();
plastNode.Release();
_variant_t varFile = "c:\\temp\\test.xml";
mXmlDom->save(varFile);
...
//release the interfaces
..
The expected content:
<?xml version="1.0" encoding="iso-8859-1"?>
<ROOT><T>X</T></ROOT>
!!!!!!!!!!!
But the content of the file is:
<?xml version="1.0" encoding="iso-8859-1"?>
<ROOT><T>&#88;</T></ROOT>
WHY
|
|
|
|
|
Hi David
a second attemt:
_bstr_t theValue("X"); is wrong !!!!
//the ASCII value 88 for the character X
//not the character itself
//I wrote it correctly but if i Submit the description the X lost in space and the X appear
// hoppfully this gives a small hint about the content of the text node:
CString text = "&" +"#" +"88;";
_bstr_t theValue(text );
|
|
|
|
|
Just do what I said... instead of _bstr_t theValue("X"); use _bstr_t theValue("&#88;"); . '&' is reserved character in XML, and X happen to be HTML (and XML) character entity for 'X'. I think in your code is same problem as what cause confusion in this forum I am only guessing now, but maybe MSXML is somehow optimized so when you give it &#xx; it will write down character with code xx - semanticaly it is the same, every XML parser will read &#xx; as character with code xx, so it is correct.(?)
David
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Hello David
I will explain the problem from scratch:
My basic problem is handling strings which only has SPACES (one or more) as content.
...
<VT> <VT>
..
I can't use the xml:space="preserve" as attribute of the tag <VT>!!!
Writing is ok but...
...If I read the generated node using
node->xml the return value is "\r\n"
or
node->text the return value is ""
Both return value don't represent the content of <VT> !!!
My first solution for this Problem was storing not the SPACES.
Store the ASCII code (32) of the SPACE instead.
Which should result in a contant similar to
..
<VT>&#32;&#32;<VT>
..
But there is no way to store this as string in a TEXT-Node.
Or in other words I didn't find a way to do this using MSXML.
I only create files with the
..
<VT>&amp;#32;&amp;#32;<VT>
..
Hopefully this will explain my problem in mor detail.
Thanks for your help
|
|
|
|
|
Yeah much clearer now.
wopa wrote:
I can't use the xml:space="preserve" as attribute of the tag <vt>!!!
Why?
What about CDATA section? I think XML procesors shouldn't normalize content of CDATA... I can't figure it out from spec, and I am lazy to try, but it could be the solution.
David
|
|
|
|
|
hi,
I am trying to use the XPath in XmlDocument object.The code is something like this
XmlDataDocument xmlDoc=new XmlDataDocument();
xmlDoc.LoadXml(xml);
XmlNode xn=xmlDoc.SelectSingleNode("//ID");
Console.WriteLine("the value of the book is:"+xmlDoc.InnerText);
and the xml file is like this
<FAX>
<JOBID>345679</JOBID>
<JOBNAME>Out1</JOBNAME>
<JOBSUBMITDATE>7/8/2005 4:27:03 PM</JOBSUBMITDATE>
<STATUS>
<ID>-1</ID>
<DESCRIPTION> Successfully Queued</DESCRIPTION>
</STATUS>
</FAX>
this is just part of the Xml their are few more tags above and below.I need only the the <ID> and <Description> values from these.
If I am coding as above then I am getting the run time error.
Can any one help me in this.
Thanking in advace,
Satish.
|
|
|
|
|
What is the runtime error ? Is it a null reference exception ? You should check that xn is not null, then you should use xn.InnerText, not xmlDoc.InnerText ( assuming you hoped to print the ID ).
Telling us the error would go a long way to telling us what is going wrong.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi Christian,
You are right the value of xn is going to null but I am unable to understand why the value of xn is null.Is my Xpath query worng.I wrote the Xpath query thinking that "//ID" will select all the <ID> tags in the Xml Document as their is only one in it it will give me the correct value.I did not choose to write the whole path (like root/child1/child2....)because in my case the Xml has SOAP envelope and body in that which have their namespaces and I dont know how to give the whole path with that.
I have also made the change xn.Innertext instead of xmlDoc.InnerText to read ID.
I have put every thing I am thinking in word.
Can you please suggest me an alternative.
I am also intrested in knowing why "//ID" is not working in this case
Thanking you,
Satish.
|
|
|
|
|
Ah - I'd say the problem is to do with the namespace the node is in. You need to search for the namespace prefix:ID, so if the namespace prefix is ns, you search for ns:ID.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello All,
I have a problem and I don't know how resolve. In a Windows 2003 Server with IIS 6 I have an ASP application that use Xml and xsl transformation. In xsl file there is a script that use the function Cos of VBScript 1.0 and when execute I receive the following error :
Error Type:
msxml4.dll (0x80020009)
Microsoft VBScript runtime error Invalid procedure call or argument: 'Cos' line = 239, col = 4 (line is offset from the start of the script block). Error returned from property or method call.
If anybody knows what is happening
The problem only is in windows 2003 server. In windows 2000 server works and in other computers with windows 2003 server also works
thanks.
|
|
|
|
|
hi all..I have a problem in making a border in the excel worksheet using spreadsheetML. I have followed the Ms Office 2003 references schema, but the code still doesn't work. Can somebody help? or maybe somebody can give me some examples how to make a border in excel using spreadsheetML. thx
This is my code:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<x:ExcelWorkbook >
<x:WindowHeight>9120</x:WindowHeight>
<x:WindowWidth>10005</x:WindowWidth>
<x:WindowTopX>120</x:WindowTopX>
<x:WindowTopY>135</x:WindowTopY>
</x:ExcelWorkbook>
<Worksheet ss:Name="Sheet1">
<ss:Table>
<ss:Row>
<ss:Cell><ss:Border ss:Position="Top"/>
<ss:Data ss:Type="Number">1</ss:Data>
</ss:Cell>
</ss:Row>
<ss:Row>
<ss:Cell ss:Index="2">
<ss:Data ss:Type="Number">3</ss:Data>
</ss:Cell>
</ss:Row>
<ss:Row ss:Index="5">
<ss:Cell ss:Index="4" ss:Formula="=R1C1+R2C2">
<ss:Data ss:Type="Number">4</ss:Data>
</ss:Cell>
</ss:Row>
</ss:Table>
</Worksheet>
</Workbook>
help me plsss!!!
|
|
|
|
|
hi,
i have the the Xml file that has lots of tags and I am intrested in retrieving the data in the first <id> tag.I used the XmlDataDocument class and the used the SelectSingleNode("//ID").
the whole code looks like this
StreamReader st= new StreamReader("c:\\temp\\abc.xml");
string xml=st.ReadToEnd();
XmlDataDocument xmlDoc=new XmlDataDocument();
xmlDoc.LoadXml(xml);
XmlNode xn=xmlDoc.SelectSingleNode("//ID");
Console.WriteLine("the value of the book is:"+xn.InnerText);
It gives me an runtime error can any one ishhelp in this.
Thanking you in advance.
Satish
|
|
|
|
|
Use the XmlDocument object instead of XmlDataDocument . Why? Well, XmlDataDocument is meant to be used in conjunction with a DataSet . It has extra functionality that you might not need.
On to the problem, do you know the name of the root element? The expression "//ID" searches all the document as compared to "/root/ID" or "root/ID" that searches under the first <root> element.
What kind of runtime error are you getting?
~Javier Lozano
|
|
|
|
|
hi Javier,
I am using XmlDocument and the code something like this
XmlDataDocument xmlDoc=new XmlDataDocument();
xmlDoc.LoadXml(xml);
XmlNode xn=xmlDoc.SelectSingleNode("//ID");
Console.WriteLine("the value of the book is:"+xn.InnerText);
and the Xml file is some thing like this
<FAX>
<JOBID>1625603</JOBID>
<JOBNAME>Out1</JOBNAME>
<JOBSUBMITDATE>7/8/2005 4:27:03 PM</JOBSUBMITDATE>
<STATUS>
<ID>-1</ID>
<DESCRIPTION> Successfully Queued</DESCRIPTION>
</STATUS>
</FAX>
Actually this this Xml is part of the SOAP response so there are few more tags up and down but I need Only the <ID> and <Description> out if it
My questions are
1)Shall I filter the SOAP then process the XMl or Shall I directly send the SOAP response to the XMLDocument.Which is advisable.
2)I tried to parse the SOAP response(because it is also Xml) with XML Document and tried to retrieve the <ID> value as shown above.I am getting the runtime error.
Kindly suggest me so way for this.
Thanking you,
Satish.
|
|
|
|
|
satishrg wrote:
1)Shall I filter the SOAP then process the XMl or Shall I directly send the SOAP response to the XMLDocument.Which is advisable.
How are you getting the SOAP response? If the data is small, then just send it to the XmlDocument
satishrg wrote:
2)I tried to parse the SOAP response(because it is also Xml) with XML Document and tried to retrieve the <ID> value as shown above.I am getting the runtime error.
What's the runtime error?
----------------------------
If you're just getting the data for the <Fax> element, then your XPath expression should be more descriptive. In other words, instead of "//ID", have it be (using the above schema) "FAX/STATUS". This will return the <STATUS> element and you can then access its children using the DOM.
Here's what I mean:
string xml = @"<FAX>
<JOBID>1625603</JOBID>
<JOBNAME>Out1</JOBNAME>
<JOBSUBMITDATE>7/8/2005 4:27:03 PM</JOBSUBMITDATE>
<STATUS>
<ID>-1</ID>
<DESCRIPTION> Successfully Queued</DESCRIPTION>
</STATUS>
</FAX>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
XmlNode xn = xmlDoc.SelectSingleNode("FAX/STATUS");
if (xn != null)
{
Console.WriteLine("ID: {0}\nDescription: {1}", xn["ID"], xn["DESCRIPTION"]);
}
~Javier Lozano
|
|
|
|
|
hi javier,
Thank you for the help.As I told you I am getting the SOAP response and it is not a big response but small So as you suggested I will use the XMLDocument class for this then in that case how do I give th Xpath for the SAOP does it look like this.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
XmlNode xn = xmlDoc.SelectSingleNode("Soap/FAX/STATUS");
if (xn != null)
{
Console.WriteLine("ID: {0}\nDescription: {1}", xn["ID"], xn["DESCRIPTION"]);
}
Thanking you,
Satish.
|
|
|
|
|
Javier Lozano wrote:
Use the XmlDocument object instead of XmlDataDocument
Or maybe XPathDocument , if he needs only retrieve data... for exactly same reasons as you said about XmlDataDocument .
David
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
hi david,
Thank you for the help.As I told you I am getting the SOAP response and it is not a big response but small So as you suggested I will use the XMLDocument class for this then in that case how do I give th Xpath for the SAOP does it look like this.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
XmlNode xn = xmlDoc.SelectSingleNode("Soap/FAX/STATUS");
if (xn != null)
{
Console.WriteLine("ID: {0}\nDescription: {1}", xn["ID"], xn["DESCRIPTION"]);
}
Thanking you,
Satish.
|
|
|
|
|
I want to make an excel program using xml and recently I read Microsoft Office 2003 references schema, but I didn't understand and when I tried the method from the book, it won't work. Can somebody tell me another source or links to learn how to make excel file using xml. Or can somebody give me some example how to do it?
|
|
|
|
|
I'm fairly new to web services, an I've run into a little difficulty that I haven't been able to find a solution for.
I need to write a web service that is basically public XmlDocument MyService(XmlDocument parameter) {...} .
The request and response XmlDocuments each need to conform to specific previously-existing XSD schema definitions.
Is there a way that I can set up a WebMethod to use an XSD file to define the content requirements of the parameter? (And likewise use yet another XSD file to define the return value?)
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM users WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Just a quick question, why are you using XmlDocument as a data transport?
~Javier Lozano
|
|
|
|
|
Because it's a B2B interface, and the specification I'm working from specifies an XML schema that the input parameter and return value have to comply with.
Since the remote client will be sending XML, and I'll have to return XML, and I use XML internally in the service, there's really not much point to converting the data from XML into some artificial object model, just to convert it back to XML.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM users WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Hi.
I'm using the GetListItems method in the List web service for sharepoint to pull a sharepoint list into an infopath document. I have that part of the code working, but how do I get the data to infopath itself?
-- Steve
|
|
|
|
|
Hi,
My requirements are that, I need to create an XML file containing data which I would retrieve from database.
What would be the best possible approach for such a problem ?
Which parsers should I opt for if I use Java as my programming language ?
Thanks and Regards,
Abdul Qadir
|
|
|
|
|
What kind of database? Can it export data as XML (e.g MSSQL can)? Is there any reason why not to use standard Java classes (JAXP) for working with XML? (link here[^])
David
|
|
|
|