Jump to content

XML experts please help me


Recommended Posts

Posted

I have to implement a packet which will be in xml format

<Printer>

         <printdata attr=here I have hexadecimaldata>

        </printdata>

</Printer>

This xml packet will be input to my one function. I need to read the  hexadecimal data and process it further.

my question is how to pass hexadecimal data and then while parsing how to parse it. I environment programming in C and embedded linux platform

Posted

 <printdata yourattr="0023233232372372">

ila pedathav value attribute lo aythe

ledu ah tag lo value pettali ante 

<printdata >008327932792323 </printdata> ila vuntundhi

iha pothe parsing antava C lo ela cheyalo teliyadu but java lo aythe manchi APIS vunayi

Posted

idedo kanipinchindhi idenemo chudu

#include <libxml/parser.h>
Posted
1 hour ago, fake_Bezawada said:

 <printdata yourattr="0023233232372372">

ila pedathav value attribute lo aythe

ledu ah tag lo value pettali ante 

<printdata >008327932792323 </printdata> ila vuntundhi

iha pothe parsing antava C lo ela cheyalo teliyadu but java lo aythe manchi APIS vunayi

array of hex bytes kaavali

like 0x123, 0x456,0x678

Posted

C# aythe you can use xml qury and  xpath to extract the data in attribute

XML Data:

<Employees>
  <EmployeeName id ="Ven234">Venkata Sreenivas</EmployeeName>
  <EmployeeAge>30</EmployeeAge>
<Employees>

Code:

XPathNavigator xpathCancelType = xPathNav.SelectSingleNode("//Employees/EmployeeName");

                if (xpathCancelType != null)
                {
                    var personID = xpathCancelType.GetAttribute("id", "");
                }

Posted
5 hours ago, BaabuBangaram said:

I have to implement a packet which will be in xml format

<Printer>

         <printdata attr=here I have hexadecimaldata>

        </printdata>

</Printer>

This xml packet will be input to my one function. I need to read the  hexadecimal data and process it further.

my question is how to pass hexadecimal data and then while parsing how to parse it. I environment programming in C and embedded linux platform

<![CDATA[]]>

 look into this tag n how to read it

Posted
29 minutes ago, karthikn said:

<![CDATA[]]>

 look into this tag n how to read it

 

Posted
3 hours ago, karthikn said:

<![CDATA[]]>

 look into this tag n how to read it

use the below code to read data from string variable

string sourceData = ""; // xml content is here

byte[] sourceBytes = Encoding.UTF8.GetBytes(sourceData);
                MemoryStream sourceStream = new MemoryStream(sourceBytes);
                
                XPathDocument sourceXPathDoc = new XPathDocument(new StringReader(sourceData));
                sourceMappingXNav = sourceXPathDoc.CreateNavigator();

Posted
17 minutes ago, MegaPowerRockstar said:

use the below code to read data from string variable

string sourceData = ""; // xml content is here

byte[] sourceBytes = Encoding.UTF8.GetBytes(sourceData);
                MemoryStream sourceStream = new MemoryStream(sourceBytes);
                
                XPathDocument sourceXPathDoc = new XPathDocument(new StringReader(sourceData));
                sourceMappingXNav = sourceXPathDoc.CreateNavigator();

pilladu c and embedded anta.. can't use this

also XDocument XElement chala better compared to XPath.. direct ga descendantnodes attributes find cheyadam

Posted
9 hours ago, BaabuBangaram said:

I have to implement a packet which will be in xml format

<Printer>

         <printdata attr=here I have hexadecimaldata>

        </printdata>

</Printer>

This xml packet will be input to my one function. I need to read the  hexadecimal data and process it further.

my question is how to pass hexadecimal data and then while parsing how to parse it. I environment programming in C and embedded linux platform

 
 
 
 
 

Hex to decimal conversion aithe

 

0x123 = (3 * 16^0) + (2 * 16^1) + (1 * 16^2)

 

basically sum of (n * 16^(reverse index of n)) for each number

if n = a, make it 10, b -> 11, c -> 12, d -> 13, e -> 14, f -> 15

 

decimal to hex conversion aithe

123

 

n = 123

first number = n %16 - (if firstnumber = 10, make it a, 11 -> b, 12 -> c, 13-> d, 14-> e, 15 -> f)

then n = n/16

secondnumber  = n % 16

...

do this till n > 0

 

 

 

 

Posted
7 hours ago, dasara_bullodu said:

Hex to decimal conversion aithe

 

0x123 = (3 * 16^0) + (2 * 16^1) + (1 * 16^2)

 

basically sum of (n * 16^(reverse index of n)) for each number

if n = a, make it 10, b -> 11, c -> 12, d -> 13, e -> 14, f -> 15

 

decimal to hex conversion aithe

123

 

n = 123

first number = n %16 - (if firstnumber = 10, make it a, 11 -> b, 12 -> c, 13-> d, 14-> e, 15 -> f)

then n = n/16

secondnumber  = n % 16

...

do this till n > 0

 

 

 

 

Direct hex bytes pampinchalem antaav anthena.......hex ni integer loki convert cheyyali antaav

Posted

array vunaya neeku hex then make multiple tags 

<Printer>

         <printdata>hex data 1</printdata>

<printdata>hex data 2</printdata>

<printdata>hex data 3</printdata>

<printdata>hex data 4</printdata>

<printdata>hex data 5</printdata>

</Printer>

parse chesi napudu motham values common tag name tho call chesthe array loki vatchesthay

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...