473,371 Members | 1,448 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,371 software developers and data experts.

Extracting more than one attribute value

I have an XML file that looks something like this
Expand|Select|Wrap|Line Numbers
  1. <MyXML>
  2.     <Stuff IDX="1"  Name="Swish" Manufacturer="Grimoto" ParentRef = "0" Ref = "1234567" />
  3.     : More elements
  4.     : More elements
  5.         <Stuff IDX="0"  Name="Swosh" Manufacturer="Grimoto" ParentRef = 1234567" Ref = "9876543" />
  6.         : More elements
  7.         : More elements
  8.         </IDX>
  9.     </IDX>
  10. <MyXML>
In the real file there are more attributes. I have managed to extract the complete Element with ParentRef = "0" using a Linq example I found on this site. Is it possible to extract a list of attributes from an Element in one hit using Linq (for instance the Name and Ref in this example) or do I have to process the Element I have extracted to get the information I want?
Oct 28 '09 #1

✓ answered by Dormilich

from what Iíve read even Linq uses somehow XPath.

nevertheless, it should be something like
Expand|Select|Wrap|Line Numbers
  1. @name or @ref
  2. @*[name() = 'name' or name() = 'ref']
to name 2 possibilities

maybe the experts in the .NET forum can tell you more when it comes to Linq.

6 3449
Dormilich
8,658 Expert Mod 8TB
of course you can get more than one attribute at a time. the question is, if that is favourable for your application.
Oct 28 '09 #2
In the real file there are 34 attributes in the Stuff element. I only want some of them extracted. The parent Id is the is Id other elements in the file that also have to have the same attributes extracted. I suppose my question should have been How do I extract multiple attributes from an Element using Linq? At the moment I think it is the most favourable way for my application.
Oct 28 '09 #3
Dormilich
8,658 Expert Mod 8TB
sorry, I canít help you with Linq (Iím not using .NET), only with the XPath.
Oct 28 '09 #4
Thanks Dormilich. What is the XPath approach to my problem?
Oct 28 '09 #5
Dormilich
8,658 Expert Mod 8TB
from what Iíve read even Linq uses somehow XPath.

nevertheless, it should be something like
Expand|Select|Wrap|Line Numbers
  1. @name or @ref
  2. @*[name() = 'name' or name() = 'ref']
to name 2 possibilities

maybe the experts in the .NET forum can tell you more when it comes to Linq.
Oct 28 '09 #6
Thanks again for your time
Oct 28 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew Lord | last post by:
XML-Schema: Attribute Value dependent rules? As far as I can tell XML-Schema does not permit the sepcification of rules that only apply if an attribute has a certain value. For example, in the...
3
by: Vineeth | last post by:
Hi, I am developing an application using the SAX interface provided by "xerces-j 2.6.0". My application does not need a DTD for execution as it is not supposed to perform any validation. I have...
5
by: Mateusz Loskot | last post by:
Hi, I'd like to ask how XML parsers should handle attributes which consists of &quot; entity as value. I know XML allows to use both: single and double quotes as attribute value terminator. That's...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
2
by: David | last post by:
Hi All I have a xml file in the format below: <root> <selection-attr select-style="dropdown" attr="a123"> <value code="A">Responce A</value> <value code="B">Responce B</value> <value...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
14
by: gooooglegroups | last post by:
I want to transform the following xml file ------------------------------------------------------------------------ <?xml version="1.0" encoding="ISO-8859-1"?> <a> <b attrib="if 3 2"> </b> ...
5
by: Oleg.Ogurok | last post by:
Hi there, I need to encode the value of an XML attribute, e.g. string myXml = "<element myAttr=\"" + encodeURIComponent("my \"value") + "\"" ...."; Is there an equivalent of...
5
by: John Nagle | last post by:
This, which is from a real web site, went into BeautifulSoup: <param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer fantastic rates for selected weeks or days!!&blinkt=Click...
4
by: Joshua Mostafa | last post by:
Hi there. I have a question regarding restrictions in an XML Schema definition. My XML contains a structure like this: <fruit-bowl> <fruit name="apple" /> <fruit name="pear" /> <fruit...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.