Hi,
I have an XML like document I want to parse... The document looks like this
:
<Form id="frmMain" width="345" height="75" HeaderHeight="9 "
image="frmMain. jpg" ColorKey="00000 0">
<Control id="btnTest1" image="btnTest1 .jpg" ColorKey="00000 0" left="10"
top="10" Width="10" Height="10" />
<Control id="btnTest2" image="btnTest2 .jpg" hovertype="beve l" left="50"
top="20" Width="10" Height="10" />
<Control id="pnlTest1" image="pnlTest1 .jpg" ColorKey="00000 0" left="100"
top="30" Width="10" Height="10" />
</Form>
I want to get the attributes names I can get on each element, because right
now I can get everything but the attribute names. here is my code :
FileStream fs = new FileStream(m_Fi lename, FileMode.Open, FileAccess.Read );
XmlReader reader = XmlReader.Creat e(fs);
while (reader.Read())
{
switch (reader.NodeTyp e)
{
case XmlNodeType.Ele ment:
{
if (reader.Name == "Form" || reader.Name == "Control")
{
string NodeKey = string.Empty;
Dictionary<stri ng, objectlst = new Dictionary<stri ng,
object>();
for (int cpt = 0; cpt < reader.Attribut eCount; cpt++)
{
string Key = ""; // HERE'S WHERE I WANT TO KNOW THE NAME
OF THE ATTRIBUTE
string Value = reader.GetAttri bute(cpt)
lst.add(Key, Value);
}
m_Elements.Add( NodeKey, lst);
}
}
break;
}
}
Does anybody know what I should do to get it?
thanks
ThunderMusic 3 6839
finally, I found it... thanks to msdn... ;) in my for loop I must do
reader.MoveToAt tribute(cpt) then the reader goes on the attribute and I can
query the name and the value of the attribute using reader.Name and
reader.Value...
thanks
ThunderMusic
"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
Hi,
I have an XML like document I want to parse... The document looks like
this :
<Form id="frmMain" width="345" height="75" HeaderHeight="9 "
image="frmMain. jpg" ColorKey="00000 0">
<Control id="btnTest1" image="btnTest1 .jpg" ColorKey="00000 0" left="10"
top="10" Width="10" Height="10" />
<Control id="btnTest2" image="btnTest2 .jpg" hovertype="beve l" left="50"
top="20" Width="10" Height="10" />
<Control id="pnlTest1" image="pnlTest1 .jpg" ColorKey="00000 0"
left="100" top="30" Width="10" Height="10" />
</Form>
I want to get the attributes names I can get on each element, because
right now I can get everything but the attribute names. here is my code :
FileStream fs = new FileStream(m_Fi lename, FileMode.Open,
FileAccess.Read );
XmlReader reader = XmlReader.Creat e(fs);
while (reader.Read())
{
switch (reader.NodeTyp e)
{
case XmlNodeType.Ele ment:
{
if (reader.Name == "Form" || reader.Name == "Control")
{
string NodeKey = string.Empty;
Dictionary<stri ng, objectlst = new Dictionary<stri ng,
object>();
for (int cpt = 0; cpt < reader.Attribut eCount; cpt++)
{
string Key = ""; // HERE'S WHERE I WANT TO KNOW THE
NAME OF THE ATTRIBUTE
string Value = reader.GetAttri bute(cpt)
lst.add(Key, Value);
}
m_Elements.Add( NodeKey, lst);
}
}
break;
}
}
Does anybody know what I should do to get it?
thanks
ThunderMusic
ThunderMusic wrote:
I want to get the attributes names I can get on each element, because right
now I can get everything but the attribute names. here is my code :
FileStream fs = new FileStream(m_Fi lename, FileMode.Open, FileAccess.Read );
XmlReader reader = XmlReader.Creat e(fs);
while (reader.Read())
{
switch (reader.NodeTyp e)
{
case XmlNodeType.Ele ment:
{
if (reader.Name == "Form" || reader.Name == "Control")
{
string NodeKey = string.Empty;
Dictionary<stri ng, objectlst = new Dictionary<stri ng,
object>();
Use a while loop e.g.
while (reader.MoveToN extAttribute()) {
lst.Add(reader. LocalName, reader.Value)
}
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
thanks... ;) that's a good way too... actually better than mine... ;)
thanks a lot
"Martin Honnen" <ma*******@yaho o.dewrote in message
news:ub******** *****@TK2MSFTNG P02.phx.gbl...
ThunderMusic wrote:
>I want to get the attributes names I can get on each element, because right now I can get everything but the attribute names. here is my code :
FileStream fs = new FileStream(m_Fi lename, FileMode.Open, FileAccess.Rea d); XmlReader reader = XmlReader.Creat e(fs); while (reader.Read()) { switch (reader.NodeTyp e) { case XmlNodeType.Ele ment: { if (reader.Name == "Form" || reader.Name == "Control") { string NodeKey = string.Empty; Dictionary<stri ng, objectlst = new Dictionary<stri ng, object>();
Use a while loop e.g.
while (reader.MoveToN extAttribute()) {
lst.Add(reader. LocalName, reader.Value)
}
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS
foreach (array('mime', 'state', 'country') as $val) {
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, ${$val . 'XML'}, ${$val .
'XMLArray'}, $tags);
xml_parser_free($parser);
$myXMLArray = ${$val . 'XMLArray'};
for...
|
by: Mudge |
last post by:
Hi,
I am a relatively new PHP programmer and I am familiar with programming
logic of web sites. I now want to get a good grasp of content and
presentation. I am trying to figure out if I should focus on XML and XSL
or CSS.
Can XML and XSL be used to show content to a browser? or can only HTML do
that?
|
by: Geiregat Jonas |
last post by:
I'm using xml.dom.minidom, I get some data by using
obj.getElementsByTagName("name") then I have an object, but how can I
get the data between the tags ? I could do .toxml() and then strip it
away. But is there a better way maybe a function made for it ?
Also is it possible using the xml.dom.minidom module to create modify an
xml file ?
|
by: Carlo Sette |
last post by:
Hi all,
when I try to Parse a sample XML ducument Python display the follow error
message:
---------------------------------------------------------------------------
Traceback (most recent call last):
File "./mysql.py", line 57, in ?
DOM=xml.dom.minidom.parseString(XML)
File "/usr/local/lib/python2.3/xml/dom/minidom.py", line 1925, in...
|
by: Gustaf Liljegren |
last post by:
I'm using xml.sax.parseString to read an XML file. The XML file contains
a few words in Russian, and is encoded in UTF-8 using C#. In the example
below, MyParser() is my SAX ContentHandler class. My first try was:
f = open('words.xml', 'r')
s = f.read()
xml.sax.parseString(s, MyParser())
This produced the following error:
| |
by: Brian Burgess |
last post by:
Hi All,
Anyone having trouble 'Load'ing xml files with 'Msxml2.DOMDocument' in ASP?
The Server is IIS 5.1 and client is PocketPC2002 (Pocket IE).
The 'Load' method is always returning 'False' for me in the following snip:
********************************************************
<%
Dim xmlAdminCfgDoc
Dim fError
|
by: Robert J Egan |
last post by:
Hi i'm trying to search a remote website page. The form returns xml
information, though the page extension is missing. I retrieve the
information and write it to the screen. So far so good - However i cannot
format this information in anyway. A copy of the returned information saved
to my server results in the xml data being formatted and...
|
by: laks |
last post by:
Hi
I have the following xsl stmt.
<xsl:for-each select="JOB_POSTINGS/JOB_POSTING
\">
<xsl:sort select="JOB_TITLE" order="ascending"/>
This works fine when I use it.
But when using multiple values in the where clause as below
|
by: UncleRic |
last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro
I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env):
PERL5LIB=/Users/Ric/Library/Perl/
ls
XML-Parser-2.34/ XML-Parser-2.34.tar
|
by: Jacker |
last post by:
Xpress Author for MS Word XML Documents
In.vision Research empowers knowledge workers to create complex XML
documents in Microsoft Word (2000-2003) with a normal Word experience.
Deploy XML authoring across the enterprise.
http://e.goozw.com/xml.htm
Powerful XML Editing Tool - XMLSPY
XMLSPY is a powerful XML tool for editing XML documents,...
|
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...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |