|
You can use XPath to contruct a query, then depending on what language you are using to implement this you could (C# exmample):
public XmlNodeList Search(string input)
{
string query = "/mainnode/subnode/[name = " + input.Trim().ToString() + "]";
XmlDocument doc = new XmlDocument();
doc.Load("mydata.xml");
XmlNodeList nodes = doc.SelectNodes(query);
return nodes;
}
Then just iterate through your return XmlNodeList 5 times. I suppose there are other ways to do this, this is just a quick example.
-Nick Parker
|
|
|
|
|
Yep, the "pure" xsl solution will be using position() I believe, like this:
"/store/books[position() <= 5]"
This will select 5 first books
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Hi
I'm trying to access a sequence which is part of a node in an XML file.
<br />
<property pr_ref="ABC" ... ><br />
<sellingpoint text="HALLWAY" /><br />
<sellingpoint text="DINING ROOM" /><br />
<sellingpoint text="KITCHEN" /><br />
</property><br />
I can iterate through the "property" nodes and retrieve their columns (pr_ref) but how on earth do I access the sequence of selling points? I've tried childrows and parents rows and I'm lost!
I'm using VB.NET and I have the entire file in a DataSet. The second table of the dataset seems to contain ALL of the sellingpoint rows, not just those related to the one property.
I'm desperate!
Bernhard
Don't worry, nobody lives forever.
|
|
|
|
|
Well, if you have created the class for handling your dataset (Generate code or something), then you should be able to use a function of propertyRow , which named like GetSellingpointRows() .
If you don't see it, then you can try using GetChildRows anyway. I can't help you much with VB, but here is a link to IBuySpy[^]. You can download a VB version and see how they did this (look in PortalCfg.vb and Components/Configuration.vb):
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Not sure this is the right forum but I have a problem generating XML for my IE Treeview Web control. With XML Explicit I get a long XML string that truncates returned data before generating the next line of code. I can only assume it's exceeded the 255 char record limit for SQL Server 2000 and is truncating data. The example in CODE PROJECT doesn't seem to address this because their sample of data is small. Any ideas? Thanks.
|
|
|
|
|
|
I have a rule that looks like this:
<xsl:template match="item" >
<item>
<xsl:apply-templates />
</item>
</xsl:template>
This matches all <item> nodes in my source document. However, the source document contains <item xsi:type="ns:AAA"> and <item xsi:type="ns:BBB"> nodes.
I want only the AAA nodes to be picked up. Any ideas...?
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Have you tried item[@xsi:type='ns:AAA'] as the match attribute?
|
|
|
|
|
Worked like a charm!
Thanks
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi..
I exported an access 2000 table to XML file
in some elements appears:
<Title>myDataHere</Title>
in some elements appears:
<Title>
<![CDATA[myDataHere]]>
</Title>
what does CDATA do ?
what if I ommit it ?
note than in cases that CDATA appears myDataHere includes (") or (..)
|
|
|
|
|
CDATA specifies a chunk of raw character data, terminated by ]]> . This allows you to embed data with characters with special meaning in XML (namely, < , > , & , and " ) without escaping them.
More info (straight from the XML spec):
http://www.w3.org/TR/REC-xml#sec-cdata-sect[^]
- Mike
|
|
|
|
|
CDATA is simply data that will not be parsed when read. For example, I have an XML help file that contains code snippets for common programming tasks. Since a lot of the characters in the code would violate XML rules and I don't want the format touched. I enter that data into my file as CDATA-type nodes.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I didn't know about this. Helpful!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Coolbeans. I'm glad I could you also.
By the way, great sig! Funny how words like that can mean different things to you depending on what you're currently going through in life.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
By the way, great sig!
Tom Archer wrote:
Funny how words like that can mean different things to you depending on what you're currently going through in life.
True.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thank you all
|
|
|
|
|
I need to access the value of a node that also contains childnodes such as
<node>
text
<child>value</child>
</node>
Inner text doesn't work because I get the child text also. I think that the way Innertext is done is pretty bad. Any Ideas? Thanks.
Steve
Steve
Not all who wander are lost...
|
|
|
|
|
You can just iterate through the children (IXMLDOMNodeList) checking the type (IXMLDOMNode::nodeType), if it is a text node (NODE_TEXT) append the value to your string otherwise keep iterating...
|
|
|
|
|
Thanks. Will this also work on .NET?
Steve
Not all who wander are lost...
|
|
|
|
|
Sure, it'll work with any DOM/Language, just the interface/method/constants names may vary slightly...
|
|
|
|
|
|
I'd like to store some data from an XML file to an Oracle Database but there is a problem with several czech characters that are not stored (interpreted, shown?) properly in the database.
The way: XML file (UTF-8 charset, czech characters put into document by using XMLSpy) --> MS-VS6, SP5 C++ program (MSXML 4, import <msxml4.dll> raw_interfaces_only) --> DOM(load method, firstChild->get_text(BSTR)) --> BSTR variable --> wchar_t* --> SQLExecDirectW --> connection string including switch to enable forcing SQLWCHARs --> Oracle DB (using Oracle Driver 9.2., CZECH_CZECH REPUBLIC.EE8ISO8859P2 in registry, all Homes) --> displayed in Toad (Arial, Central European). Some characters are replaced by similar ones, some of them can't be recognized.
Please, help!
|
|
|
|
|
I see now, that Excel is showing the data properly. Toad doesn't...
|
|
|
|
|
Can anyone tell me how generate a sample XML instance from a XSD file.
|
|
|
|
|
Is there a way to specify a search root to selectSingleNode?
it always gives me the first hit in the file even if the Node that is calling the function is located after the node that gets found.
for example, in file
<forms count="2">
__
____<item>1<\Item>
__
__
____<item>2<\Item>
__
(for some reason the opening Item tags dissapear when i post)
How should I Locate Item 2(In c++) without using child or nextsibling pointers(I cant guarantee the order of the child Items)
|
|
|
|