473,698 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract XML using Dotnet

Hi Guys,

I want to populate a nodelist so that i can extract various details.
The xml document i have is similar to the one below. baiscally i want
to extract the first instance of <PP> including <PP1> <PP2> <PP3> then
separately extract the next instance of <PP> <PP1> <PP2> <PP3>. Does
anyone have any examples on how to do this ??? Im trying to create an
html table using these values but its a bit of a nightmare.

any help appreciated
<Text>
<Header>
</Header>
<Details>
<PP>LASU</PP>
<PP1>A</PP2>
<PP2>B</PP2>
<PP3>C</PP3>
<PP>REFUSE</PP>
<PP1>1</PP2>
<PP2>2</PP2>
<PP3>3</PP3>
</Details>
<Details>
<PP>test1</PP>
<PP1>A</PP2>
<PP2>B</PP2>
<PP3>C</PP3>
<PP>test2</PP>
<PP1>1</PP2>
<PP2>2</PP2>
<PP3>3</PP3>
</Details>
</Text>

May 15 '06 #1
1 1650


csgraham74 wrote:

I want to populate a nodelist so that i can extract various details.
The xml document i have is similar to the one below. baiscally i want
to extract the first instance of <PP> including <PP1> <PP2> <PP3> then
separately extract the next instance of <PP> <PP1> <PP2> <PP3>. Does
anyone have any examples on how to do this ???
With .NET you can either use Xml(Text)Reader or an XPathDocument and
XPathNodeIterat or to do this, the following is a C# example using
XPathDocument and XPathNodeIterat or
XPathDocument document = new XPathDocument(@ "file.xml") ;
XPathNavigator navigator = document.Create Navigator();
XPathNodeIterat or nodeIterator =
navigator.Selec t("Text/Details/PP/text()");
while (nodeIterator.M oveNext()) {
Console.Write(" PP: {0}: ", nodeIterator.Cu rrent.Value);
XPathNodeIterat or nodeIterator2 = nodeIterator.Cu rrent.Select(
"../following-sibling::*[position() < 4]/text()");
while (nodeIterator2. MoveNext()) {
Console.Write(" {0}, ", nodeIterator2.C urrent.Value);
}
Console.WriteLi ne();
}
}
}
Note that you example is not even well-formed XML, you need to close the
<PP1> with </PP1>
<PP1>A</PP2>

^^^^^^

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
16976
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and extract 35 characters (including "T") from a file and then go to next line?
3
4823
by: julien | last post by:
Hello, Assembly.FullName give information about a DLL, including the version w.x.y.z. Is there a way to extract the version directly from the assembly, or do I have to extract it from Assembly.FullName? Thank you Julien
5
22007
by: steve | last post by:
How can someone extract the file name and file path from a complete path? ex: c:\mydir\subdir\temp\myfile.txt will give: path = c:\mydir\subdir\temp filename = myfile.txt TIA
5
1190
by: mamatha | last post by:
Hi I want an application to extract e-mailID's from webpage or from local harddisk.I don't have that much of knowledge in extracting emails from the webpage.If anybody knows source code or URL's of that related sites let me know. Thanks in advance Mamatha
4
4022
by: Patrick | last post by:
I've got some text with a few HTML tags, such as the following <Bold>Hello</Bold>There buddy<p>please ..... I need to be able to extract just the text, which would be Hello there buddy please.... Note, this is a Windows App, and not a Web App. Any ideas anyone?
3
30783
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word Document and save it to a new Word Document. I would need to generate a loop for each page found within a word document to create a new word document and insert the existing page into the new word document and then save as a new word document. ...
8
2833
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module for this task. Actually, I have two different log files. The first file looks like: ...
2
1875
by: Spam Catcher | last post by:
Hi all, Does .NET provide any native API calls to extract .DLL/.EXE icon files based on IconIndex? Is there a way to enumerate through all the icons in an assembly (.NET or Native code assemblies)? Thanks!
5
5758
by: Steve | last post by:
Hi all Does anybody please know a way to extract an Image from a pdf file and save it as a TIFF? I have used a scanner to scan documents which are then placed on a server, but I need to extract the image of the document (just the first page if there are multiple pages) and save it as a TIFF so I can then use the Tesseract OCR to get the text in the image.
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.