|
I am trying to write a simple program that loads an xml file but i can not link this program, I am following this tutorial
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/dom_hdi_30dv.asp
Could any body help?
#include <stdio.h>
#include <msxml2.h>
#include <windows.h>
#pragma comment(lib,"msxml2.lib")
int main()
{
HRESULT hr;
IXMLDOMDocument3 *pXMLDoc = NULL;
IXMLDOMParseError * pObjError = NULL;
BSTR bstr = NULL;
VARIANT_BOOL status;
VARIANT var;
CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument40,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument3,
(void**)&pXMLDoc);
return 0;
}
|
|
|
|
|
Did you install the MSXML 4 SDK ? (see MS platform SDK site for the update).
Once installed, you still need to add the path to the msxml2.lib file in either your project settings (additional library path), or your VisualStudio general directories (tools / options / directories).
|
|
|
|
|
Hi.
I have data in XML format and I use XslTransform.Transform to transform the data to a presentable form with an xsl-file. At one location I have used for instance
<xsl:apply-templates select="//TermR[termid=$intd]"/> to select what TermR data to use, where $intd is some variable. If I want to use two conditions, for example I only want to use TermR data where termid=$intd AND term2=$intp , is this possible? How do I write the selection in my xsl-code?
Thanks
/EnkelIk
|
|
|
|
|
You should be able to use it just like that:
<xsl:if test="termid=$intd AND term2=$intp">
"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
|
|
|
|
|
Thanks. Why did I not think of the simplest solution? For the select case the following turned out to work:
<xsl:apply-templates select="//TermR[termid=$intd][term2=$intp]"/>
i.e. just adding up the conditions.
/EnkelIk
|
|
|
|
|
XSL
I'm making some output be bold only if a certain condition is true:
<xsl:if test="test"><b></xsl:if>
Now the problem is, all end tags must directly match up with their start tags (i.e. you can't do "<b><i></b></i>" - you have to do "<b><i></i></b><i></i>"). But I'm wanting the "<b>" tag only to be outputted only if the test condition is true. Short of having seperate block for each combination of <b>, <i>, <u>, etc, how do I do it?
I've thought of using script to concatenate a <b>:
function GetTag(text)
GetTag=Chr(60) + text + Chr(62)
end function
Or can someone show me a better way?
"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
|
|
|
|
|
The 'politically correct' way is probably to use the xsl:element tag e.g.
<xsl:choose>
<xsl:when test="test">
<xsl:element name="b">
Your Content
</xsl:element>
</xsl:when>
<xsl:otherwise>
Your Content
</xsl:otherwise>
</xsl:choose>
This is easy enough if your content is in another rule or a function or something - not so easy otherwise...but it does make sure you've got all tags paired correctly.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Stuart Dootson wrote:
to use the xsl:element tag
Now why didn't I remember that one! THANKS!!!
"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
|
|
|
|
|
And also remember xsl:attribute when you need to add attributes to elements
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Yep. You can bet I immediately looked up <xsl:element> and its related tags on MSDN as soon as I saw this! Thanks again!
"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
|
|
|
|
|
or even
<xsl:choose><br />
<xsl:when test="test"><br />
<b>Your Content</b><br />
</xsl:when><br />
<xsl:otherwise>Your Content</xsl:otherwise></xsl:choose>
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I did say 'the politically correct way'....;P
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
This is precicsely what I was trying to avoid.
"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
|
|
|
|
|
an even better way would be (xhtml & css2):
<span><br />
<xsl:if test="test"><br />
<xsl:attribute name="style">font-weight: bold</xsl:attribute><br />
</xsl:if><br />
Your Content<br />
</span>
hope this helps
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Yep. That's what I'm doing. Thanks!
"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
|
|
|
|
|
|
sorry.. this is the XML example
<node><br />
<a ..../><br />
<c ..../><br />
<c ..../><br />
<a ..../><br />
<a ..../><br />
<a ..../><br />
<d ..../><br />
<d ..../><br />
</node>
|
|
|
|
|
<node>
<a ..../>
<c ..../>
<c ..../>
<a ..../>
<a ..../>
<a ..../>
<d ..../>
<d ..../>
</node>
|
|
|
|
|
node.selectNodes("*/*[name() != '" + myVar + "']").length
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Does anyone know how to put a carriage return/linefeed sequence in an XML quoted string? I tried
&
&
<br/> , etc. Help would be much appreciated.
"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
|
|
|
|
|
An quoted string can have carriage returns. There is no escaping sequence for it, so that's why
etc. don't do anything.
To answer your question, I need to know if you are just editing an Xml file by hand, or trying to tweak an xml file writer.
If you are editing by hand, then just add carriage returns. It's compatible with the Xml snytax rules.
Otherwise, depending on the language you are using to generate the xml file, make sure to add \r and\n to exported strings.
|
|
|
|
|
This is what I had thought, but when I do it that way, my whole XML file's display goes nuts.
I am just doing an XML file by hand with an XSLT transform.
Thanks for your help!
"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
|
|
|
|
|
Can i change the msxml parser version that internt explorer use to load the xml document? if yes, how?
eg. IE6.0 use MSXML3.0 SP2, how can i force it to use other version, like MSXML4.0?
|
|
|
|
|
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
|
|
|
|