|
I think simple cases as such should not have any problems. Places where you'd run into issues is when Xslt groups/aggregates and/or sorts the data.
Though bit challenging, you'll have to make sure that the formatting does not change when going XML->HTML. If it does, you'll have to take care of the special case.
I'm not sure if the following is a typo. But if it is not, then your conversion from HTML->XML will lose "Chapter 1" value.
dnh wrote:
My Article
- Malhar
|
|
|
|
|
malharone wrote:
I think simple cases as such should not have any problems. Places where you'd run into issues is when Xslt groups/aggregates and/or sorts the data.
I agree.
malharone wrote:
I'm not sure if the following is a typo. But if it is not, then your conversion from HTML->XML will lose "Chapter 1" value.
yeah damnit, I forgot that It should be only quick example... But you have the idea... and since none of us know how exactly eggie's XML/HTML/XSLT looks like, we won't get anywhere I guess.
David
|
|
|
|
|
hello..
i'm trying to do a system which the crystal report will display the data generate from my class coding.
but i know one way is to use xml to read the data from calss first. and then crystal report only can display the data from xml file....
how can i do that? totally no idea on how to do...
if anyone knows that, pls help.... thanks a lot
|
|
|
|
|
Hi all,
I'm using VB.NET and I can read my XML into a dataset and display it into a DataGrid with no problem. But what I would like to do (if possible) is select certain elements via an id attribute.
For example, if my XML had the following nodes:
<mynode id="someid">innertext
<mynode id="someid">someother innertext
<mynode id="someid">more innertext
<mynode id="someotherID">innertext
How would I be able to display on those nodes with id="someid" and bind my dataset to my Datagrid.
Is this even possible to do or will I have to create another XML document to parse and hold only those specific nodes?
Any help would be much appreciated! Thanks.
|
|
|
|
|
|
Hi,
what I try to do is only to store a string like "&88;" in a XML file using MSXML.
but I got only this content.
<root>
<t>X
What wrong, or were is the missing link?
here is the example code which I use:
.....
HRESULT hr;
IXMLDOMDocument2Ptr mXmlDom;
IXMLDOMNodePtr mRoot4Write;
try {
hr= mXmlDom.CreateInstance(__uuidof(DOMDocument40));
if (FAILED(hr) || mXmlDom == NULL) {
mXmlDom= NULL;
} else {
mXmlDom->put_resolveExternals( false);
mXmlDom->put_async( false);
mXmlDom->put_validateOnParse( true);
mXmlDom->setProperty("NewParser", VARIANT_TRUE );
mXmlDom->put_preserveWhiteSpace(true);
CString csRootNameStart("ROOT");
CString csRootNameEnd("ROOT");
CString csXML;
_bstr_t bstrXML;
csXML.Format("%s\n<%s>\n\n",CDF_PROCESSING_INSTRUCTION, csRootNameStart, csRootNameEnd);
bstrXML = csXML;
if(mXmlDom->loadXML(bstrXML)) {
mRoot4Write = mXmlDom->selectSingleNode(_bstr_t(csRootNameStart));
_variant_t nodetyp;
nodetyp = (long)NODE_ELEMENT;
IXMLDOMNodePtr plastNode = mXmlDom->createNode(nodetyp,_bstr_t("T"),_bstr_t(""));
plastNode = mRoot4Write->appendChild(plastNode);
m_Text.GetWindowText(csXML);
IXMLDOMNodePtr pNode = mXmlDom->createTextNode(_bstr_t(csXML));
pNode = plastNode->appendChild(pNode);
pNode.Release();
_bstr_t parsed;
parsed = plastNode->text;
m_Parsed.SetWindowText(parsed);
plastNode.Release();
_variant_t varFile = "c:\\temp\\test.xml";
hr = mXmlDom->save(varFile);
}
mRoot4Write.Release();
mXmlDom.Release();
}
}
catch (_com_error& er) {
_bstr_t parsed = er.Description();
m_Parsed.SetWindowText(parsed);
mXmlDom= NULL;
}
catch (...) {
mXmlDom= NULL;
}
|
|
|
|
|
wopa wrote:
what I try to do is only to store a string like "&88;" in a XML
&88; is recognized as entity. If you want literal "&88;", then you must encode & as & (as XML spec. says). I am not sure how you do it in your code, since you obviously didn't bother to read your post after yourself - fix your post, and then maybe somebody will help you more...
David
|
|
|
|
|
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.
|
|
|
|