|
Hi,
I have a small project: I have an XML file as input, and I need to find certain "tokens" inside it. For example, I need to find all of the "Prop1" properties (and their values), inside all "TAG1" tags:
<tag1>
..
Prop1=value1 <<-- I need to find this
..
I have no idea how to work with XML. Also, I'm looking for sth that works on NT4.0 sp5 without the need to install anything. Where do I start?????
Thanks.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
sagmam wrote:
Where do I start?????
Here[^].
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
sagmam wrote:
Also, I'm looking for sth that works on NT4.0 sp5 without the need to install anything.
I dunno if you're going to find that, you probably need the Microsoft XML stuff installed. I could be wrong about that, but certainly your starting point is XSL, the language used to generate a document from input XML. I should probably do some articles, but either way, there's plenty of info on the web.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
A few questions.
What do you mean by properties. In XML you can have child elements
<Tag1>
<ChildElement> data </ChildElement>
</Tag1>
or Attributes of an element
<Tag1 childattribute="data"/>
Second. Can you clarify what you mean by without installing anything?
If you mean not installing any dll's (i.e. not updating the MSXML updates) only, that is quite different than anything. i.e. if you have a code only solution you still need to install it.
I will assume you mean the first case, so code only is ok.
If that is correct my code found here at
http://www.codeproject.com/soap/xmlmabparser.asp (sorry no clickty with html turned off for XML sample.)
can be edited to not include the MSXML parsing feature and use only an internal parser. The internal parser is about 1/10 th as fast though and please read my caveats on how text blocks are handled.
From there it is just a matter of stepping through the child elements of all elements looking for the data sets you wish, via the first/next child element functions.
|
|
|
|
|
I meant the attributes. At least, this is what I need at the moment.
I'll look into it, thanks.
|
|
|
|
|
How can i transform following XML file:
<br />
<data><br />
<item name="One" /><br />
<item name="Two" /><br />
</data><br />
to something like this:
- One
- Two
?
(i do not know how to get value of name in item)
Thank you
|
|
|
|
|
May I suggest doing a search for:
XSLT value-of
in google. Now the key to answer your question is the "value-of"
Now what your are wanting is the value of something in an element.
The first item in my search lead me to this page
http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#element-value-of
As it turns out it is a good staring point. Notice sample in the copy section. It uses a select statement with an '@' prior to the name they are looking for. In a select if the name is preceeded by the '@' sign it is looking for an attribute of the element that is the current focus. With out it the select would be looking for the child element of that name.
A nother site to book mark is http://wdvl.com/Authoring/Tutorials/xml.html They have several introductions to XSLT that will cover this material.
This http://wdvl.com/Authoring/Languages/XSL/Quickly/ is one that is on their first page now.
|
|
|
|
|
use @ to get to attributes:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><br />
<br />
<xsl:output method="text" encoding="iso-8859-1" indent="no" /><br />
<br />
<xsl:template match="data"><br />
<xsl:apply-templates select="item"/><br />
</xsl:template><br />
<br />
<xsl:template match="item"><br />
- <xsl:value-of select="@name"/><br />
</xsl:template><br />
<br />
</xsl:stylesheet>
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Can I make Squirrel mail support Unicode ?
|
|
|
|
|
hello!
this is the xml/xsl area not the mail area
shesh
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
But it's worth it to find out someone is called 'Hung Son'. What a cool name.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
But it's worth it to find out someone is called 'Hung Son'
Your kids giving you grief again?
Paul Watson Bluegrass Cape Town, South Africa Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson
|
|
|
|
|
That's not actually what I was thinking of....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I think asking about php on a site geared towards everything but is asking for trouble. It's like going into a linux discussion and asking for help with a windows xp installation.
PHP is great imho.
http://www.php.net/
http://www.phpbuilder.com/
http://www.zend.com/
http://www.phpwizard.net/
also, #php on irc.openprojects.net is great.
ciao
|
|
|
|
|
NRK wrote:
PHP is great imho.
Have you tried ASP.NET? I totally agree that ASP and PHP are on level terms and there is not much in it. But ASP.NET is something totally different and better. I hope PHP keeps up, good to have options and competition
Paul Watson Bluegrass Cape Town, South Africa Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson
|
|
|
|
|
Hi Gurus!
I'm a XML beginner. I try to save my program settings in XML file using Microsoft Visual C++ 6.0. Here is the sample from my code:
--------------------------------------------------------------
IXMLDOMDocumentPtr XmlDocPtr;
IXMLDOMNodePtr pNode;
IXMLDOMElementPtr XmlRootPtr;
b=XmlDocPtr->loadXML(_bstr_t("<settings>"));
if (!b) return;
XmlDocPtr->get_documentElement(&XmlRootPtr);
if (XmlRootPtr)
{
VARIANT vtTemp2;
vtTemp2.vt=VT_I2;
vtTemp2.iVal = NODE_ELEMENT;
pNode = XmlDocPtr->createNode(vtTemp2, "Program", "");
pNode->put_dataType(L"NODE_TEXT");
pNode->put_text(L"MYCOOLER");
XmlRootPtr->appendChild(pNode);
pNode = XmlDocPtr->createNode(vtTemp2, "Distributor", "");
pNode->put_dataType(L"NODE_TEXT");
pNode->put_text(L"IBM Corp.");
XmlRootPtr->appendChild(pNode);
pNode = XmlDocPtr->createNode(vtTemp2, "Version", "");
pNode->put_dataType(L"NODE_TEXT");
pNode->put_text(L"6.0");
XmlRootPtr->appendChild(pNode);
};
variant_t vDest(L"d:\\settings.xml");
XmlDocPtr->save(vDest);
--------------------------------------------------------------
File d:\system.dtd contains:
--------------------------------------------------------------
--------------------------------------------------------------
But resulted file "settings.xml" is not formatted according system.dtd specification. What's wrong? Help me!
Yours sincerely,
Alex Bash
|
|
|
|
|
Bash wrote:
But resulted file "settings.xml" is not formatted according system.dtd specification.
The DTD is not a formatter. A DTD is just here to verify the well-formedness and/or validness of an Xml stream.
The formatting is the result of your own code (appendChild, ...).
On top of that, when you open an Xml file in MSIE, MSIE applies a default formatting (using a XSLT stylesheet) : for instance it may show you <k name="kkk"/> although there is <k name="kkk"></k> in the file.
Back to real work : D-27.
|
|
|
|
|
Hi,
Thank you for quick reply to the beginner. And another question - how to insert CR/LF symbol after appending a new child. At present, I have "settings.xml" with single line like as:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Settings><Program>MYCOOLER</Program><Distributor>IBM Corp.</Distributor><Version>6.0</Version></Settings>
I want to get this xml (i.e. "formatted") as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Settings>
<Program>MYCOOLER</Program>
<Distributor>IBM Corp.</Distributor>
<Version>6.0</Version>
</Settings>
How to do "formatted" xml?
Yours sincerely,
Alex Bash
|
|
|
|
|
Unfortunately, there is no way to do so using MSXML. That's probably why this SDK is now legacy and replaced by a much more powerful Xml stuff along with .NET.
You can achieve indentation by creating your own fake text nodes, with code like this :
var dom = new ActiveXObject("Microsoft.XMLDOM");
var root = dom.createElement("toto");
for (i = 0; i < 10; i++) {
var formatting = dom.createTextNode("\n\t");
root.appendChild(formatting);
var child = dom.createElement(child);
root.appendChild(child);
}
dom.save("output.xml");
Back to real work : D-27.
|
|
|
|
|
Thank you, it works!
Yours sincerely,
Alex Bash
|
|
|
|
|
Do you know what would cause the construction of a Xerxes DOM parser to die? It seems like this should be valid, but I'm obviously missing something.
DOMParser* pDomParser = new DOMParser();
ASSERT (pDomParser != NULL);
delete pDomParser;
Are we required to derive from DOMParser and override certain methods? Btw, I'm using a prebuilt binary of the XML4C 4.0.0 implementation. A ptr to the API docs would also be much appreciated. Thanks!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Are you calling the Initialize routine?
XMLPlatformUtils::Initialize();
What version are you using if not?
"We are what we repeatedly do. excellence, then, is not an act, but a habit." Aristotle
|
|
|
|
|
Thanks Michael, that did the trick!
I ended up with a purported memory leak, but the Xerxes docs say the diagnostic overagressive and can be ignored. I then switched from XML4C V4 to V5 and encountered a new problem:
When I build my (simple) Xerces test project, VC++ complains that DOMDocument (present in several Xerces header files) is an ambiguous symbol. The clash seems to occur as a result of the Platform SDK (Aug 2002) being installed on my system. Do you know how I get around this problem?
Thanks,
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I actually have not used the Xerces C since last Jan, so I am afraid no.
Have you downloaded the current release. There was an update the end of August so maybe it was addressed with that revision.
"We are what we repeatedly do. excellence, then, is not an act, but a habit." Aristotle
|
|
|
|
|
Yes, I'm using the latest release. I've switched back to version 4 to get around the symbol clash. Thanks for your help!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|